Learn R Programming

sjstats (version 0.16.0)

icc: Intraclass-Correlation Coefficient

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

icc(x, ...)

# S3 method for stanreg icc(x, re.form = NULL, typical = "mean", prob = 0.89, ppd = FALSE, ...)

# S3 method for brmsfit icc(x, re.form = NULL, typical = "mean", prob = 0.89, ppd = FALSE, ...)

Arguments

x

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

...

Currently not used.

re.form

Formula containing group-level effects to be considered in the prediction. If NULL (default), include all group-level effects. Else, for instance for nested models, name a specific group-level effect to calculate the ICC for this group-level. Only applies if ppd = TRUE.

typical

Character vector, naming the function that will be used as measure of central tendency for the ICC. The default is "mean". See typical_value for options.

prob

Vector of scalars between 0 and 1, indicating the mass within the credible interval that is to be estimated. See hdi.

ppd

Logical, if TRUE, variance decomposition is based on the posterior predictive distribution, which is the correct way for Bayesian non-Gaussian models.

Value

A numeric vector with all random intercept intraclass-correlation-coefficients. Furthermore, between- and within-group variances as well as random-slope variance are returned as attributes. For stanreg or brmsfit objects, the HDI for each statistic is also included as attribute.

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 refer to Stryhn et al. (2006). Aly et al. (2014) describe computation of ICC for negative binomial models.

Caution: For models with random slopes and random intercepts, the ICC would differ at each unit of the predictors. Hence, the ICC for these kind of models cannot be understood simply as proportion of variance (see Goldstein et al. 2010). For convenience reasons, as the icc() function also extracts the different random effects variances, the ICC for random-slope-intercept-models is reported nonetheless, but it is usually no meaningful summary of the proportion of variances.

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

If ppd = TRUE, icc() calculates a variance decomposition based on the posterior predictive distribution. In this case, first, the draws from the posterior predictive distribution not conditioned on group-level terms (posterior_predict(..., re.form = NA)) are calculated as well as draws from this distribution conditioned on all random effects (by default, unless specified else in re.form) are taken. Then, second, the variances for each of these draws are calculated. The "ICC" is then the ratio between these two variances. This is the recommended way to analyse random-effect-variances for non-Gaussian models. It is then possible to compare variances accross models, also by specifying different group-level terms via the re.form-argument.

Sometimes, when the variance of the posterior predictive distribution is very large, the variance ratio in the output makes no sense, e.g. because it is negative. In such cases, it might help to use a more robust measure to calculate the central tendency of the variances. For example, use typical = "median".

References

  • Aguinis H, Gottfredson RK, Culpepper SA. 2013. Best-Practice Recommendations for Estimating Cross-Level Interaction Effects Using Multilevel Modeling. Journal of Management 39(6): 1490<U+2013>1528 (10.1177/0149206313478188)

  • Aly SS, Zhao J, Li B, Jiang J. 2014. Reliability of environmental sampling culture results using the negative binomial intraclass correlation coefficient. Springerplus 14(3) (10.1186/2193-1801-3-40)

  • Goldstein H, Browne W, Rasbash J. 2010. Partitioning Variation in Multilevel Models. Understanding Statistics, 1:4, 223-231 (10.1207/S15328031US0104_02)

  • Grace-Martion K. The Intraclass Correlation Coefficient in Mixed Models, web

  • Hox J. 2002. Multilevel analysis: techniques and applications. Mahwah, NJ: Erlbaum

  • Rabe-Hesketh S, Skrondal A. 2012. Multilevel and longitudinal modeling using Stata. 3rd ed. College Station, Tex: Stata Press Publication

  • Raudenbush SW, Bryk AS. 2002. Hierarchical linear models: applications and data analysis methods. 2nd ed. Thousand Oaks: Sage Publications

  • Stryhn H, Sanchez J, Morley P, Booker C, Dohoo IR. 2006. Interpretation of variance parameters in multilevel Poisson regression models. Proceedings of the 11th International Symposium on Veterinary Epidemiology and Economics, 2006 Available at http://www.sciquest.org.nz/node/64294

  • Wu S, Crespi CM, Wong WK. 2012. Comparison of methods for estimating the intraclass correlation coefficient for binary responses in cancer prevention cluster randomized trials. Contempory Clinical Trials 33: 869-880 (10.1016/j.cct.2012.05.004)

Further helpful online-ressources:

See Also

re_var

Examples

Run this code
# NOT RUN {
library(lme4)
fit0 <- lmer(Reaction ~ 1 + (1 | Subject), sleepstudy)
icc(fit0)

# note: ICC for random-slope-intercept model usually not
# meaningful - see 'Note'.
fit1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
icc(fit1)

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

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

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

# }
# NOT RUN {
# compute ICC for Bayesian mixed model, with an ICC for each
# sample of the posterior. The print()-method then shows
# the median ICC as well as 89% HDI for the ICC.
# Change interval with print-method:
# print(icc(m, posterior = TRUE), prob = .5)

if (requireNamespace("brms", quietly = TRUE)) {
  library(dplyr)
  sleepstudy$mygrp <- sample(1:5, size = 180, replace = TRUE)
  sleepstudy <- sleepstudy %>%
    group_by(mygrp) %>%
    mutate(mysubgrp = sample(1:30, size = n(), replace = TRUE))
  m <- brms::brm(
    Reaction ~ Days + (1 | mygrp / mysubgrp) + (1 | Subject),
    data = sleepstudy
  )

  # by default, 89% interval
  icc(m)

  # show 50% interval
  icc(m, prob = .5)

  # variances based on posterior predictive distribution
  icc(m, ppd = TRUE)
}
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab