View source: R/multilevel.icc.R
multilevel.icc | R Documentation |
This function computes the intraclass correlation coefficient ICC(1), i.e., proportion of the total variance explained by the grouping structure, and ICC(2), i.e., reliability of aggregated variables.
multilevel.icc(x, cluster, type = 1, method = c("aov", "lme4", "nlme"), REML = TRUE,
as.na = NULL, check = TRUE)
x |
a vector, matrix or data frame. |
cluster |
a vector representing the nested grouping structure (i.e., group or cluster variable). |
type |
numeric value indicating the type of intraclass correlation
coefficient, i.e., |
method |
a character string indicating the method used to estimate
intraclass correlation coefficients, i.e., |
REML |
logical: if |
as.na |
a numeric vector indicating user-defined missing values,
i.e. these values are converted to |
check |
logical: if |
Note that this function is restricted to two-level models.
Returns a numeric vector with intraclass correlation coefficient(s).
Takuya Yanagida takuya.yanagida@univie.ac.at
Hox, J., Moerbeek, M., & van de Schoot, R. (2018). Multilevel analysis: Techniques and applications (3rd. ed.). Routledge.
Snijders, T. A. B., & Bosker, R. J. (2012). Multilevel analysis: An introduction to basic and advanced multilevel modeling (2nd ed.). Sage Publishers.
multilevel.descript
dat <- data.frame(id = c(1, 2, 3, 4, 5, 6, 7, 8, 9),
cluster = c(1, 1, 1, 1, 2, 2, 3, 3, 3),
x1 = c(2, 3, 2, 2, 1, 2, 3, 4, 2),
x2 = c(3, 2, 2, 1, 2, 1, 3, 2, 5),
x3 = c(2, 1, 2, 2, 3, 3, 5, 2, 4))
# ICC(1) for x1
multilevel.icc(dat$x1, cluster = dat$cluster)
# ICC(1) for x1, convert value 1 to NA
multilevel.icc(dat$x1, cluster = dat$cluster, as.na = 1)
# ICC(2) for x1
multilevel.icc(dat$x1, cluster = dat$cluster, type = 2)
# ICC(1) for x1,
# use lmer() function in the lme4 package to estimate ICC
multilevel.icc(dat$x1, cluster = dat$cluster, method = "lme4")
# ICC(1) for x1, x2, and x3
multilevel.icc(dat[, c("x1", "x2", "x3")], cluster = dat$cluster)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.