Learn R Programming

JWileymisc (version 0.3.1)

iccMixed: Intraclass Correlation Coefficient (ICC) from Mixed Models

Description

This function estimates the ICC from mixed effects models estimated using lme4.

Usage

iccMixed(dv, id, data, family = c("gaussian", "binomial"))

Arguments

dv

A character string giving the variable name of the dependent variable.

id

A character vector of length one or more giving the ID variable(s). Can be more than one.

data

A data.table containing the variables used in the formula. This is a required argument. If a data.frame, it will silently coerce to a data.table. If not a data.table or data.frame, it will attempt to coerce, with a message.

family

A character vector giving the family to use for the model. Currently only supports “gaussian” or “binomial”.

Value

A data table of the ICCs

References

For details, see Campbell, M. K., Mollison, J., & Grimshaw, J. M. (2001). Cluster trials in implementation research: estimation of intracluster correlation coefficients and sample size. Statistics in Medicine, 20(3), 391-399.

Examples

Run this code
# NOT RUN {
iccMixed("mpg", "cyl", mtcars)
iccMixed("mpg", "cyl", as.data.table(mtcars))
iccMixed("mpg", "cyl", as.data.table(mtcars), family = "gaussian")
iccMixed("mpg", c("cyl", "am"), as.data.table(mtcars))
iccMixed("am", "cyl", as.data.table(mtcars), family = "binomial")
# }

Run the code above in your browser using DataLab