View source: R/multilevel.fit.R
| multilevel.fit | R Documentation |
This function provides simultaneous and level-specific model fit information using the partially saturated model method for multilevel models estimated with the lavaan package. Note that level-specific fit indices cannot be computed when the fitted model contains cross-level constraints, e.g., equal factor loadings across levels in line with the metric cross-level measurement invariance assumption.
multilevel.fit(model, print = c("all", "summary", "fit"), digits = 3, p.digits = 3,
write = NULL, append = TRUE, check = TRUE, output = TRUE)
model |
a fitted multilevel model of class |
print |
a character string or character vector indicating which results
to show on the console, i.e. |
digits |
an integer value indicating the number of decimal places
to be used for displaying results. Note that loglikelihood,
information criteria and chi-square test statistic is
printed with |
p.digits |
an integer value indicating the number of decimal places to be used for displaying the p-value. |
write |
a character string naming a file for writing the output into
either a text file with file extension |
append |
logical: if |
check |
logical: if |
output |
logical: if |
Returns an object of class misty.object, which is a list with following
entries:
call |
function call |
type |
type of analysis |
args |
specification of function arguments |
model.fit |
a fitted model of class |
result |
list with result tables, i.e., |
The function uses the functions fitmeasures, lavInspect,
lavTech, and parTable provided in the R package lavaan by
Yves Rosseel (2012).
Takuya Yanagida takuya.yanagida@univie.ac.at
Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48, 1-36. https://doi.org/10.18637/jss.v048.i02
multilevel.cfa, multilevel.invar,
multilevel.omega, multilevel.cor,
multilevel.descript
## Not run:
# Load data set "Demo.twolevel" in the lavaan package
data("Demo.twolevel", package = "lavaan")
#————————————————————————————————————————————————————————————————————————————
# Model Specification and Model Estimation
# Load lavaan package
library(lavaan)
# Model specification
model <- 'level: 1
fw =~ y1 + y2 + y3
fw ~ x1 + x2 + x3
level: 2
fb =~ y1 + y2 + y3
fb ~ w1 + w2'
# Model estimation with estimator = "ML"
fit1 <- sem(model = model, data = Demo.twolevel, cluster = "cluster", estimator = "ML")
# Model estimation with estimator = "MLR"
fit2 <- sem(model = model, data = Demo.twolevel, cluster = "cluster", estimator = "MLR")
#————————————————————————————————————————————————————————————————————————————
# Simultaneous and Level-Specific Multilevel Model Fit Information
# Example 1a: Standard fit indices
multilevel.fit(fit1)
# Example 1b: Standard, scaled, and robust fit indices
multilevel.fit(fit2)
#————————————————————————————————————————————————————————————————————————————
# Write Results
# Example 2a: Write results into a text file
multilevel.fit(fit1, write = "LS-Fit1.txt")
# Example 2b: Write results into an Excel file
multilevel.fit(fit2, write = "LS-Fit2.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.