View source: R/multilevel.descript.R
multilevel.descript | R Documentation |
This function computes descriptive statistics for multilevel data, e.g. average cluster size, variance components, intraclass correlation coefficient, design effect, and effective sample size.
multilevel.descript(x, cluster, print = c("all", "var", "sd"),
method = c("aov", "lme4", "nlme"), REML = TRUE,
digits = 2, icc.digits = 3, as.na = NULL, write = NULL,
check = TRUE, output = TRUE)
x |
a vector, matrix or data frame. |
cluster |
a vector representing the nested grouping structure (i.e., group or cluster variable). |
print |
a character string or character vector indicating which results to
show on the console, i.e. |
method |
a character string indicating the method used to estimate
intraclass correlation coefficients, i.e., |
REML |
logical: if |
digits |
an integer value indicating the number of decimal places to be used. |
icc.digits |
an integer indicating the number of decimal places to be used for displaying intraclass correlation coefficients. |
as.na |
a numeric vector indicating user-defined missing values,
i.e. these values are converted to |
write |
a character string for writing the results into a Excel file
naming a file with or without file extension '.xlsx', e.g.,
|
check |
logical: if |
output |
logical: if |
Note that this function is restricted to two-level models.
Returns an object of class misty.object
, which is a list with following
entries:
call |
function call |
type |
type of analysis |
data |
data frame specified in |
args |
specification of function arguments |
model.fit |
fitted lavaan object ( |
result |
list with result tables, i.e., |
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.
write.result
, multilevel.icc
, descript
## Not run:
# Load data set "Demo.twolevel" in the lavaan package
data("Demo.twolevel", package = "lavaan")
#---------------------------
# Cluster variable specification
# Cluster variable 'cluster' in 'x'
multilevel.descript(Demo.twolevel[, c("y1", "cluster")], cluster = "cluster")
# Cluster variable 'cluster' not in 'x'
multilevel.descript(Demo.twolevel$y1, cluster = Demo.twolevel$cluster)
#---------------------------
# Multilevel descriptive statistics for y1
multilevel.descript(Demo.twolevel$y1, cluster = Demo.twolevel$cluster)
# Multilevel descriptive statistics for y1, print variance and standard deviation
multilevel.descript(Demo.twolevel$y1, cluster = Demo.twolevel$cluster, print = "all")
# Multilevel descriptive statistics for y1, print ICC with 5 digits
multilevel.descript(Demo.twolevel$y1, cluster = Demo.twolevel$cluster, icc.digits = 5)
# Multilevel descriptive statistics for y1
# use lme() function in the nlme package to estimate ICC
multilevel.descript(Demo.twolevel$y1, cluster = Demo.twolevel$cluster, method = "nlme")
# Multilevel descriptive statistics for y1, y2, y3, w1, and w2
multilevel.descript(Demo.twolevel[, c("y1", "y2", "y3", "w1", "w2")],
cluster = Demo.twolevel$cluster)
# Write Results into a Excel file
multilevel.descript(Demo.twolevel[, c("y1", "y2", "y3", "w1", "w2")],
cluster = Demo.twolevel$cluster, write = "Multilevel_Descript.xlsx")
result <- multilevel.descript(Demo.twolevel[, c("y1", "y2", "y3", "w1", "w2")],
cluster = Demo.twolevel$cluster, output = FALSE)
write.result(result, "Multilevel_Descript.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.