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(x, print = c("all", "summary", "fit"), digits = 3, p.digits = 3,
write = NULL, append = TRUE, check = TRUE, output = TRUE)
x |
a fitted 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 |
x |
a fitted model of class |
args |
specification of function arguments |
model |
specified models, i.e., |
result |
list with result tables, i.e., |
The function uses the functions cfa
, 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
model <- 'level: 1
fw =~ y1 + y2 + y3
fw ~ x1 + x2 + x3
level: 2
fb =~ y1 + y2 + y3
fb ~ w1 + w2'
#-------------------------------------------------------------------------------
# Example 1: Model estimation with estimator = "ML"
fit1 <- lavaan::sem(model = model, data = Demo.twolevel, cluster = "cluster",
estimator = "ML")
# Simultaneous and level-specific multilevel model fit information
ls.fit1 <- multilevel.fit(fit1)
# Write results into a text file
multilevel.fit(fit1, write = "LS-Fit1.txt")
# Write results into an Excel file
write.result(ls.fit1, "LS-Fit1.xlsx")
# Example 2: Model estimation with estimator = "MLR"
fit2 <- lavaan::sem(model = model, data = Demo.twolevel, cluster = "cluster",
estimator = "MLR")
# Simultaneous and level-specific multilevel model fit information
# 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.