Skip to contents

For each requested entry (i, k) of Lambda_<level>, refit the model with that entry pinned to a grid of values and return the resulting log-likelihood curve. The output is a long data.frame with class profile_loadings; pass it to plot() to visualise the classic LR U-shape, or to loading_ci() (via method = "profile") to invert the curve and get CIs that do NOT depend on the fit's Hessian being positive-definite.

Usage

loading_profile(
  fit,
  level = c("unit", "unit_obs"),
  entries = NULL,
  n_grid = 11L,
  grid_extent = 6,
  conf_level = 0.95
)

Arguments

fit

A confirmatory gllvmTMB() multi-trait fit.

level

Which loading matrix: "unit" (default) or "unit_obs". Legacy "B"/"W" accepted with deprecation.

entries

Optional matrix or data.frame of (i, k) index pairs specifying which Lambda entries to profile. Default NULL profiles every entry that is NOT pinned (i.e. every free entry the data informs). Pinned entries are skipped.

n_grid

Integer; number of grid points per entry. Default 11.

grid_extent

Numeric; total grid width as a multiple of a robust scale estimate of the loading (default 6 — i.e. estimate ± 3 scale units on each side). At pdHess-OK fits the scale is the Wald SE; otherwise a heuristic based on |Lambda|/2 + 0.5.

conf_level

Confidence level for the eventual CI inversion; stored on the output for downstream consumers.

Value

A data.frame of class profile_loadings with columns: trait, axis, i, k, profile_value, objective (the negative log-likelihood evaluated at that value), delta_deviance (= 2 * (objective - min(objective))), estimate, conf_level. Pinned entries do not appear in the output.

Details

This is expensive: each entry requires n_grid partial refits, so a 20-species 2-factor fit at default n_grid = 11 is ~440 fits. For binary probit at the scale of this article's fixture, expect minutes. Use entries to restrict to a subset when iterating.

See also

loading_ci() for the inverted-CI version, plot.profile_loadings() for the U-shape visualisation.

Examples

if (FALSE) { # \dontrun{
pf <- loading_profile(fit, level = "unit")
plot(pf)                              # all entries faceted
loading_ci(fit, method = "profile")   # inverts pf internally
} # }