Skip to contents

Full-rank unstructured \(T \times T\) additive-genetic covariance matrix \(\boldsymbol G\), parameterised as the Cholesky factor of a rank-\(T\) \(\boldsymbol\Lambda\) (i.e. the animal_latent() case with \(K = T\)). Mathematical parallel to phylo_dep().

Usage

animal_dep(formula, pedigree = NULL, A = NULL, Ainv = NULL)

Arguments

formula

An lme4-bar formula of the form 0 + trait | id.

pedigree, A, Ainv

See animal_scalar().

Value

See animal_scalar().

Examples

if (FALSE) { # \dontrun{
# Full unstructured additive-genetic trait covariance (rank = n_traits).
# 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_dep(0 + trait | species, A = A),
  data = df, family = gaussian()
)
} # }