extract_varcomp {lmeInfo} | R Documentation |
Extract estimated variance components
Description
Extracts the estimated variance components from a fitted linear mixed effects model (lmeStruct object) or generalized least squares model (glsStruct object).
Usage
extract_varcomp(mod, separate_variances, vector)
Arguments
mod |
Fitted model of class lmeStruct or glsStruct. |
separate_variances |
Logical indicating whether to return the separate
level-1 variance components for each stratum if using |
vector |
Logical indicating whether to return the variance components as
a numeric vector. Default is |
Value
If vector = FALSE
, an object of class varcomp
consisting of a
list of estimated variance components. Models that do not include
correlation structure parameters or variance structure parameters will have
empty lists for those components. If vector = TRUE
, a numeric vector
of estimated variance components.
If separate_variances = TRUE
and if weights =
varIdent(form = ~ 1 | Stratum)
is specified in the model fitting, separate
level-1 variance estimates will be returned for each stratum. If
separate_variances = TRUE
but if the weighting structure is not
specified with varIdent
, or if separate_variances = FALSE
,
then no separate level-1 variance estimates will be returned.
Examples
library(nlme)
data(Bryant2016)
Bryant2016_RML <- lme(fixed = outcome ~ treatment,
random = ~ 1 | school/case,
correlation = corAR1(0, ~ session | school/case),
weights = varIdent(form = ~ 1 | treatment),
data = Bryant2016)
extract_varcomp(Bryant2016_RML, separate_variances = FALSE)
extract_varcomp(Bryant2016_RML, separate_variances = TRUE)
extract_varcomp(Bryant2016_RML, vector = TRUE)