# NOT RUN {
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))
# Multilevel descriptive statistics for x1
multilevel.descript(dat$x1, cluster = dat$cluster)
# Multilevel descriptive statistics for x1, print ICC with 5 digits
multilevel.descript(dat$x1, cluster = dat$cluster, icc.digits = 5)
# Multilevel descriptive statistics for x1, convert value 1 to NA
multilevel.descript(dat$x1, cluster = dat$cluster, as.na = 1)
# Multilevel descriptive statistics for x1,
# use lmer() function in the lme4 package to estimate ICC
multilevel.descript(dat$x1, cluster = dat$cluster, method = "lme4")
# Multilevel descriptive statistics for x1, x2, and x3
multilevel.descript(dat[, c("x1", "x2", "x3")], cluster = dat$cluster)
# }
Run the code above in your browser using DataLab