Learn R Programming

sjstats (version 0.2.0)

get_re_var: Random effect variances

Description

This function extracts specific components from the random effect variances or the random-intercept-slope-correlation of mixed effects models. Currently, only merMod objects are supported.

Usage

get_re_var(x, comp = c("tau.00", "tau.01", "tau.11", "rho.01", "sigma_2"))

Arguments

x
An object of class icc.lme4, as returned by the icc function, or a fitted mixed effects model (merMod-class).
comp
Name of the variance component to be returned. See 'Details'.

Value

The required variance component.

Details

The random effect variances indicate the between- and within-group variances as well as random-slope variance and random-slope-intercept correlation. Use following values for comp to get the particular variance component:
"sigma_2"
Within-group (residual) variance

"tau.00"
Between-group-variance (variation between individual intercepts and average intercept)

"tau.11"
Random-slope-variance (variation between individual slopes and average slope)

"tau.01"
Random-Intercept-Slope-covariance

"rho.01"
Random-Intercept-Slope-correlation

See Also

icc and re_var

Examples

Run this code
library(lme4)
fit <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)

# icc
icc(fit)

# all random effect variance components
re_var(fit)

# just the rand. slope-intercept covariance
get_re_var(fit, "tau.01")

sleepstudy$mygrp <- sample(1:45, size = 180, replace = TRUE)
fit <- lmer(Reaction ~ Days + (1 | mygrp) + (Days | Subject), sleepstudy)
get_re_var(fit, "rho.01")

Run the code above in your browser using DataLab