icc: Intraclass-Correlation Coefficient

Description Usage Arguments Details Value Note References See Also Examples

View source: R/icc.R

Description

This function calculates the intraclass-correlation (icc) - sometimes also called variance partition coefficient (vpc) - for random intercepts of mixed effects models. Currently, merMod, glmmTMB stanreg and brmsfit objects are supported.

Usage

1
icc(x, ...)

Arguments

x

Fitted mixed effects model (of class merMod, glmmTMB, stanreg or brmsfit).

...

More fitted model objects, to compute multiple intraclass-correlation coefficients at once.

Details

The ICC is calculated by dividing the between-group-variance (random intercept variance) by the total variance (i.e. sum of between-group-variance and within-group (residual) variance).

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:

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.

Note

Some notes on why the ICC is useful, based on Grace-Martin:

In short, the ICC can be interpreted as “the proportion of the variance explained by the grouping structure in the population” (Hox 2002: 15).

Usually, the ICC is calculated for the null model ("unconditional model"). However, according to Raudenbush and Bryk (2002) or Rabe-Hesketh and Skrondal (2012) it is also feasible to compute the ICC for full models with covariates ("conditional models") and compare how much a level-2 variable explains the portion of variation in the grouping structure (random intercept).

Caution: For three-level-models, depending on the nested structure of the model, the ICC only reports the proportion of variance explained for each grouping level. However, the proportion of variance for specific levels related to each other (e.g., similarity of level-1-units within level-2-units or level-2-units within level-3-units) must be computed manually. Use get_re_var to get the between-group-variances and residual variance of the model, and calculate the ICC for the various level correlations.

For example, for the ICC between level 1 and 2:
sum(get_re_var(fit)) / (sum(get_re_var(fit)) + get_re_var(fit, "sigma_2"))

or for the ICC between level 2 and 3:
get_re_var(fit)[2] / sum(get_re_var(fit))

References

Further helpful online-ressources:

See Also

re_var

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(lme4)
fit0 <- lmer(Reaction ~ 1 + (1 | Subject), sleepstudy)
icc(fit0)

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(fit0, fit1, fit2)

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

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

sjstats documentation built on Nov. 23, 2017, 1:05 a.m.