Adds slope-only predictor deviations across response columns, with an
additive-genetic relationship matrix \(A\) relating those columns. If
B is the response-column by predictor coefficient matrix, the model is
$$\mathrm{Cov}(\mathrm{vec}(B^\mathsf{T})) =
A \otimes \Sigma_\mathrm{predictor}.$$
The RHS must be the response-column factor resolved from trait =, and the
pedigree or matrix labels must match its levels. A single | estimates a
full predictor covariance; || gives separate predictor variances with
zero covariance. The term never adds a random intercept.
Arguments
- formula
An lme4-bar formula. With one or more bare predictors and the resolved response-column factor on the RHS,
x1 + x2 | traitis the full column-slope covariance alias andx1 + x2 || traitis its diagonal alias. For one predictor the two bars fit the same1 x 1covariance.- pedigree, A, Ainv
One relatedness input for the column-slope aliases: a pedigree, additive-genetic covariance matrix, or its precision.
Details
This route is covered for Gaussian long-format data with bare finite numeric
predictors. Wide-format column slopes, non-Gaussian responses, transformed
or factor bases, latent predictor covariance, and intervals are not
supported in this release. Use
extract_Sigma(fit, level = "column_slope") for
\(\Sigma_\mathrm{predictor}\).
Historical non-trait RHS forms remain accepted to preserve existing fits. They are compatibility behaviour, not the teaching API; new code uses the resolved response-column factor on the RHS.
Examples
if (FALSE) { # \dontrun{
set.seed(1); ids <- paste0("sp", 1:4); A <- diag(4); dimnames(A) <- list(ids, ids)
dat <- expand.grid(unit = factor(1:12), trait = factor(ids, levels = ids))
dat$elevation <- rnorm(nrow(dat))
dat$forest_cover <- rnorm(nrow(dat))
dat$value <- rnorm(nrow(dat))
fit <- gllvmTMB(value ~ 0 + trait + animal_slope(elevation + forest_cover | trait, A = A),
data = dat, trait = "trait", unit = "unit", family = gaussian())
extract_Sigma(fit, level = "column_slope")
} # }
