Skip to contents

Adds a per-individual random slope on a continuous covariate x, with individual-level slopes correlated according to the additive- genetic relatedness matrix \(\mathbf A\). Mathematically: $$\eta_{io} \;\mathrel{{+}{=}}\; \beta_{\text{a}}(i)\, x_{io}, \qquad \boldsymbol\beta_{\text{a}} \sim \mathcal{N}\bigl(\mathbf 0,\, \sigma^2_{\text{slope}}\,\mathbf A\bigr).$$

Usage

animal_slope(formula)

Arguments

formula

An lme4-bar formula of the form x | id.

Value

See animal_scalar().

Details

This is the canonical quantitative-genetic random-regression (reaction-norm) model – heritable variation in the slope on an environmental gradient. Mathematical parallel to phylo_slope(); the engine recycles the same \(\mathbf A^{-1}\) prepared by animal_scalar() / animal_latent().

Examples

if (FALSE) { # \dontrun{
# Additive-genetic random regression: one heritable slope variance on a
# continuous covariate x, slopes correlated by the relatedness matrix A.
# Grounded in test-animal-slope-recovery.R.
ped <- data.frame(
  id   = paste0("i", 1:12),
  sire = c(rep(NA, 4), rep(c("i1", "i2"), length.out = 8)),
  dam  = c(rep(NA, 4), rep(c("i3", "i4"), length.out = 8))
)
A <- pedigree_to_A(ped)
df <- expand.grid(
  species = factor(rownames(A), levels = rownames(A)),
  trait   = factor(c("t1", "t2", "t3")),
  rep     = 1:5
)
df$x <- rnorm(nrow(df))
df$value <- rnorm(nrow(df))
fit <- gllvmTMB(
  value ~ 0 + trait + animal_slope(x | species, A = A),
  data = df, unit = "species", cluster = "species"
)
} # }