Skip to contents

Returns one row per trait and latent axis from a fitted gllvmTMB() model. This is the report-ready companion to rotate_loadings() and to plot(type = "ordination"): the same rotation, axis-ordering, sign-anchor, and optional loading-standardization conventions are recorded in columns instead of left inside a matrix.

Usage

extract_rotated_loadings_table(
  fit,
  level = "unit",
  method = c("varimax", "promax", "none"),
  order_axes = TRUE,
  sign_anchor = c("auto", "none"),
  anchor_traits = NULL,
  loading_scale = c("raw", "standardized")
)

Arguments

fit

A fitted multivariate model returned by gllvmTMB().

level

"unit" (between-unit) or "unit_obs" (within-unit). Deprecated aliases "B" and "W" are still accepted with a warning.

method

One of "varimax", "promax", or "none"; passed to rotate_loadings().

order_axes

Logical. When TRUE, reorder rotated axes by decreasing raw shared variance before tabulation. Ignored when method = "none".

sign_anchor

One of "auto" or "none". "auto" flips each rotated axis so its anchor trait has a positive loading. Ignored when method = "none".

anchor_traits

Optional character vector of trait names used for sign anchoring. Supply one trait per axis after ordering. Axes without a supplied anchor use the trait with the largest absolute loading.

loading_scale

One of "raw" or "standardized". "raw" returns the rotated loadings on the fitted response scale. "standardized" divides each trait loading by the square root of that trait's model-implied total variance, matching plot(type = "ordination", standardize_loadings = TRUE).

Value

A data frame with columns level, trait, axis, loading, abs_loading, axis_variance, axis_share, rotation, order_axes, sign_anchor, anchor_trait, and loading_scale. axis_variance and axis_share are computed from the rotated raw loading matrix before any optional standardization; these are the quantities used to order axes.

Details

Scope: covered for fitted latent() components at level = "unit" or level = "unit_obs" with raw or standardized point-estimate loadings. This table does not attach uncertainty intervals to loadings. Bootstrap or simulation-based uncertainty is not yet implemented and remains possible future work for a later inference slice.

Examples

if (FALSE) { # \dontrun{
sim <- simulate_site_trait(
  n_sites = 60, n_species = 12, n_traits = 4,
  Lambda_B = matrix(c(1.0, 0.7, -0.3, 0.5,
                      0.3, -0.5, 0.8, 0.2),
                    nrow = 4, ncol = 2),
  psi_B = c(0.3, 0.3, 0.3, 0.3),
  seed = 1
)
fit <- gllvmTMB(value ~ 0 + trait +
                        latent(0 + trait | site, d = 2),
                data  = sim$data,
                trait = "trait",
                unit  = "site")
extract_rotated_loadings_table(
  fit,
  level = "unit",
  method = "varimax",
  loading_scale = "standardized"
)
} # }