extract_varcomp: Extract estimated variance components

View source: R/information-matrices.R

extract_varcompR 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 varIdent function to allow for different variances per stratum. Default is FALSE.

vector

Logical indicating whether to return the variance components as a numeric vector. Default is FALSE.

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)


lmeInfo documentation built on April 17, 2023, 9:08 a.m.