# 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 lme() function in the nlme package to estimate ICC
multilevel.descript(dat$x1, cluster = dat$cluster, method = "nlme")
# Multilevel descriptive statistics for x1, x2, and x3
multilevel.descript(dat[, c("x1", "x2", "x3")], cluster = dat$cluster)
# }
# NOT RUN {
# Write Results into a Excel file
result <- multilevel.descript(dat[, c("x1", "x2", "x3")], cluster = dat$cluster,
output = FALSE)
write.result(result, "Multilevel_Descript.xlsx")
# }
Run the code above in your browser using DataLab