Skip to contents

[Deprecated]

Usage

animal_unique(id, pedigree = NULL, A = NULL, Ainv = NULL)

Arguments

id

Bare column name of the individual factor.

pedigree

A 3-column data frame with columns id, sire, dam (unknown parents encoded as NA). Converted internally to A via Henderson's recursive formula. Only one of pedigree, A, or Ainv should be given.

A

Dense relatedness matrix (\(n \times n\)); rownames / colnames must match levels of id.

Ainv

Precision matrix (inverse of A). Sparse matrix inputs are preserved for the sparse engine route.

Value

See animal_scalar().

Details

animal_unique() is soft-deprecated as compatibility syntax in gllvmTMB 0.2.0. Use animal_indep() for standalone marginal diagonal animal-model terms. Paired explicit-Psi use remains accepted; use animal_latent(..., unique = TRUE) when the folded latent term itself should carry this diagonal companion.

Canonical name for the D independent animal-model random intercept on a shared relatedness matrix \(\mathbf A\). Each trait gets its own variance \(\sigma^{2}_{\text{a},t}\); traits share the same per-individual draws (rows of A act on each trait independently). Mathematical parallel to phylo_unique().

Correlated intercept + slope reaction norm

Used with an intercept+slope bar, animal_unique(1 + x | id, pedigree = ped) fits a correlated additive-genetic random-regression (reaction norm) \(\mathrm{vec}(\mathbf B) \sim N(0, \Sigma_b \otimes \mathbf A)\), where \(\Sigma_b\) is a \(2 \times 2\) (intercept, slope) covariance with a free intercept-slope correlation. This routes through the same augmented engine as phylo_unique() with a 1 + x | sp bar; no separate likelihood. For the diagonal (\(\rho = 0\)) special case use animal_indep() with the same 1 + x | id bar. Recover \(\Sigma_b\) with extract_Sigma(fit, level = "phy").

Examples

if (FALSE) { # \dontrun{
# Per-trait independent additive-genetic variances on a shared A.
# Grounded in test-animal-keyword.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)
yvec <- as.numeric(MASS::mvrnorm(
  1, mu = rep(0, 2 * 12),
  Sigma = kronecker(diag(2), A) * 0.5 + diag(2 * 12) * 0.5
))
df <- data.frame(
  species = factor(rep(ped$id, each = 2), levels = ped$id),
  trait   = factor(rep(c("t1", "t2"), times = 12), levels = c("t1", "t2")),
  value   = yvec
)
fit <- gllvmTMB(
  value ~ 0 + trait + animal_unique(species, pedigree = ped),
  data = df, family = gaussian()
)
} # }