The compareModels
function compares the output of two Mplus files and prints similarities and
differences in the model summary statistics and parameter estimates. Options are provided
for filtering out fixed parameters and nonsignificant parameters. When requested, compareModels
will compute the chi-square difference test for nested models (does not apply to MLMV, WLSM, and WLSMV
estimators, where DIFFTEST in Mplus is needed).
compareModels(
m1,
m2,
show = "all",
equalityMargin = c(param = 1e-04, pvalue = 1e-04),
compare = "unstandardized",
sort = "none",
showFixed = FALSE,
showNS = TRUE,
diffTest = FALSE
)
A list containing the results of the comparison. Elements include
summaries
with selected summary statistics for both models,
parameters
listing equal and differing parameters as well as those
unique to each model, and, when diffTest = TRUE
, a diffTest
element with the chi-square difference test.
The first Mplus model to be compared. Generated by readModels
.
The second Mplus model to be compared.
What aspects of the models should be compared. Options are "all", "summaries", "equal", "diff", "pdiff", and "unique". See below for details.
Defines the discrepancy between models that is considered equal. Different margins can be specified for p-value equality versus parameter equality. Defaults to .0001 for both.
Which parameter estimates should be compared. Options are "unstandardized", "stdyx.standardized" "stdy.standardized", and "std.standardized".
How to sort the output of parameter comparisons. Options are "none", "type", "alphabetical", and "maxDiff". See below for details.
Whether to display fixed parameters in the output (identified
where the est/se = 999.000, per Mplus convention). Default to FALSE
.
Whether to display non-significant parameter estimates. Can be
TRUE
or FALSE
, or a numeric value (e.g., .10) that defines
what p-value is filtered as non-significant.
Whether to compute a chi-square difference test between the models. Assumes that the models are nested. Not available for MLMV, WLSMV, and ULSMV estimators. Use DIFFTEST in Mplus instead.
Michael Hallquist
Model outputs to be compared should come from the readModels
command.
The show
parameter can be one or more of the following, which can be
passed as a vector, such as c("equal", "pdiff").
"all"
: Display all available model comparison. Equivalent to
c("summaries", "equal", "diff", "pdiff", "unique")
.
"summaries"
: Print a comparison of model summary statistics. Compares
the following summary statistics (where available):
c("Title", "Observations", "Estimator", "Parameters", "LL", "AIC", "BIC", "ChiSqM_Value", "ChiSqM_DF", "CFI", "TLI", "RMSEA", "SRMR", "WRMR")
.
"allsummaries"
: Print a comparison of all summary statistics available
in each model. May generate a lot of output.
"equal"
: Print parameter estimates that are equal between models
(i.e., <= equalityMargin["param"]
).
"diff"
: Print parameter estimates that are different between models
(i.e., > equalityMargin["param"]
).
"pdiff"
: Print parameter estimates where the p-values differ between
models (i.e., > equalityMargin["pvalue"]
).
"unique"
: Print parameter estimates that are unique to each model.
The sort
parameter determines the order in which parameter estimates
are displayed. The following options are available:
"none"
: No sorting is performed, so parameters are output in the order
presented in Mplus. (Default)
"type"
: Sort parameters by their role in the model. This groups output
by regression coefficient (ON), factor loadings (BY), covariances (WITH),
and so on. Within each type, output is alphabetical.
"alphabetical"
: Sort parameters in alphabetical order.
"maxDiff"
: Sort parameter output by the largest differences between
models (high to low).