
Suggest a lambda_constraint matrix for a reduced-rank GLLVM
Source: R/suggest-lambda-constraint.R
suggest_lambda_constraint.RdProduces a sensible default constraint matrix M that resolves the
rotational ambiguity of the reduced-rank loadings Lambda in models of
the form
value ~ 0 + trait + latent(0 + trait | site, d = K) + .... The matrix is
returned in the format expected by gllvmTMB()'s lambda_constraint
argument: NA in free entries, numeric in pinned entries.
Arguments
- fit_or_formula
Either a fitted
gllvmTMB_multiobject or a formula. If a formula,datamust also be supplied.- data
A data frame. Required when
fit_or_formulais a formula; ignored when it is a fit.- level
Which loading matrix to constrain:
"B"(between-site, default) or"W"(within-site).- convention
One of:
"lower_triangular"(default)Pin every upper-triangular entry to 0, i.e.
M[i, j] = 0forj > i. Removes the rotational ambiguity completely. PinsK(K-1)/2entries."pin_top_one"Single-anchor convention:
M[1, 1] = 1, restNA. Sets the scale of factor 1; does NOT remove rotational ambiguity."none"All-
NAmatrix – no pins. Useful if you plan to apply post-hoc rotation (e.g. varimax) instead.
- trait, unit
Name of the trait and unit (site) columns. Forwarded when
fit_or_formulais a formula and the data does not already use defaults.- site
Deprecated alias for
unit. Emits a one-shot warning and maps tounit.
Value
A list with components:
constraintA
T x Kmatrix withNAin free entries and 0 (or 1, for"pin_top_one") in pinned entries. Has trait names as rownames and"f1", ..., "fK"as colnames.conventionThe chosen convention.
dThe number of factors
K.n_pinsNumber of pinned entries.
noteA short explanation of what was pinned and why.
usage_hintAn example call as a string showing how to use the returned matrix with
gllvmTMB().