VarCorr.glmmTMB: Extract variance and correlation components

Description Usage Arguments Details Examples

Description

Extract variance and correlation components

Usage

1
2
## S3 method for class 'glmmTMB'
VarCorr(x, sigma = 1, ...)

Arguments

x

a fitted glmmTMB model

sigma

residual standard deviation (usually set automatically from internal information)

extra

arguments (for consistency with generic method)

Details

For an unstructured variance-covariance matrix, the internal parameters are structured as follows: the first n parameters are the log-standard-deviations, while the remaining n(n-1)/2 parameters are the elements of the Cholesky factor of the correlation matrix, filled in column-wise order (see the TMB documentation for further details).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Comparing variance-covariance matrix with manual computation
data("sleepstudy",package="lme4")
fm4 <- glmmTMB(Reaction ~ Days + (Days|Subject), sleepstudy)
VarCorr(fm4)[[c("cond","Subject")]]
## hand calculation
pars <- getME(fm4,"theta")
## construct cholesky factor
L <- diag(2)
L[lower.tri(L)] <- pars[-(1:2)]
C <- crossprod(L)
diag(C) <- 1
sdvec <- exp(pars[1:2])
(V <- outer(sdvec,sdvec) * C)

Example output

Warning message:
In checkMatrixPackageVersion() : Package version inconsistency detected.
TMB was built with Matrix version 1.2.10
Current Matrix version is 1.2.11
Please re-install 'TMB' from source or restore original 'Matrix' package
            (Intercept)     Days
(Intercept)   565.51607 11.05534
Days           11.05534 32.68221
attr(,"stddev")
(Intercept)        Days 
  23.780582    5.716836 
attr(,"correlation")
            (Intercept)       Days
(Intercept)  1.00000000 0.08131936
Days         0.08131936 1.00000000
          [,1]     [,2]
[1,] 565.51607 10.95613
[2,]  10.95613 32.68221

glmmTMB documentation built on July 20, 2021, 9:06 a.m.