Learn R Programming

sjstats (version 0.2.0)

icc: Intraclass-Correlation Coefficient

Description

This function calculates the intraclass-correlation (icc) for random intercepts of mixed effects models. Currently, only merMod objects are supported.

Usage

icc(x, ...)

Arguments

x
Fitted mixed effects model (merMod-class).
...
More fitted model objects, to compute multiple intraclass-correlation coefficients at once.

Value

A numeric vector with all random intercept intraclass-correlation-coefficients, or a list of numeric vectors, when more than one model were used as arguments. Furthermore, between- and within-group variances as well as random-slope variance are returned as attributes.

Details

The calculation of the ICC for generalized linear mixed models with binary outcome is based on Wu et al. (2012). For Poisson multilevel models, please refere to Stryhn et al. (2006). Aly et al. (2014) describe computation of ICC for negative binomial models. There is a print-method that prints the variance parameters using the comp-argument set to "var": print(x, comp = "var") (see 'Examples'). The re_var-function is a convenient wrapper. The random effect variances indicate the between- and within-group variances as well as random-slope variance and random-slope-intercept correlation. The components are denoted as following:
  • Within-group (residual) variance: sigma_2
  • Between-group-variance: tau.00 (variation between individual intercepts and average intercept)
  • Random-slope-variance: tau.11 (variation between individual slopes and average slope)
  • Random-Intercept-Slope-covariance: tau.01
  • Random-Intercept-Slope-correlation: rho.01

References

See Also

re_var to print random effect variances and get_re_var to get the values from a particular variance component.

Examples

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

sleepstudy$mygrp <- sample(1:45, size = 180, replace = TRUE)
fit2 <- lmer(Reaction ~ Days + (1 | mygrp) + (Days | Subject), sleepstudy)
icc(fit2)

# return icc for all models at once
icc(fit1, fit2)

icc1 <- icc(fit1)
icc2 <- icc(fit2)

print(icc1, comp = "var")
print(icc2, comp = "var")


Run the code above in your browser using DataLab