Skip to contents

Fit response-column-specific random intercepts and/or slopes with an animal covariance supplied as a pedigree, relationship covariance A, or inverse relationship matrix Ainv. The fitted covariance across the coefficient basis is full for | and diagonal for ||.

Usage

animal_coef(formula, pedigree = NULL, A = NULL, Ainv = NULL, rho = 1)

Arguments

formula

A coefficient-basis bar expression such as 1 + x | trait, 0 + x | trait, or 1 + x || trait.

pedigree

A pedigree accepted by the animal covariance helpers. Mutually exclusive with A and Ainv.

A

A labelled animal relationship covariance matrix. Mutually exclusive with pedigree and Ainv.

Ainv

A labelled animal relationship precision matrix. Mutually exclusive with pedigree and A.

rho

One numeric value in [0, 1] fixing the animal source mixture.

Value

A formula marker; never evaluated directly.

Details

This point-model route is covered for Gaussian multivariate data in long or traits(...) wide form. The first public version accepts a fixed numeric rho in [0, 1]. Estimated source strength, interval inference, and non-Gaussian coefficient models are not available. Existing animal_slope() remains current and warning-free.

For exact compatibility with the released slope engine, a no-intercept dense-A fit with rho = 1 uses the existing animal_slope() conditioning seam, A + 1e-8 I. Pedigree and sparse-Ainv endpoints use their released sparse precision. Interior rho and intercept-bearing rho = 1 fits use the raw covariance-scale mixture.

Examples

set.seed(3)
dat <- expand.grid(unit = factor(1:12), trait = factor(paste0("sp", 1:3)))
dat$x <- rnorm(12)[dat$unit]
dat$value <- rnorm(nrow(dat))
A <- 0.4 ^ abs(outer(1:3, 1:3, "-"))
dimnames(A) <- list(levels(dat$trait), levels(dat$trait))
fit <- gllvmTMB(value ~ 1 + animal_coef(1 + x | trait, A = A, rho = 0.5),
  data = dat, trait = "trait", unit = "unit", family = gaussian(),
  control = gllvmTMBcontrol(se = FALSE), silent = TRUE)
extract_Sigma(fit, level = "column_coef")
#> $Sigma
#>              (Intercept)           x
#> (Intercept)  0.001544038 -0.01793465
#> x           -0.017934651  0.20831865
#> 
#> $R
#>             (Intercept)          x
#> (Intercept)   1.0000000 -0.9999996
#> x            -0.9999996  1.0000000
#> 
#> $level
#> [1] "column_coef"
#> 
#> $part
#> [1] "dep"
#> 
#> $basis
#> [1] "(Intercept)" "x"          
#> 
#> $source
#> $source$type
#> [1] "animal"
#> 
#> $source$grouping
#> [1] "trait"
#> 
#> $source$labels
#> [1] "sp1" "sp2" "sp3"
#> 
#> 
#> $rho
#> [1] 0.5
#> 
#> $rho_status
#> [1] "fixed"
#> 
#> $K_rho
#>      sp1 sp2  sp3
#> sp1 1.00 0.2 0.08
#> sp2 0.20 1.0 0.20
#> sp3 0.08 0.2 1.00
#> 
#> $note
#> [1] "Response-column coefficient covariance; the response-column source supplies the other Kronecker factor."
#>