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). Model outputs to be compared can be full summaries and parameters (generated by readModels), summary statistics only (extractModelSummaries), or parameters only (extractModelParameters).

compareModels(
  m1,
  m2,
  show = "all",
  equalityMargin = c(param = 1e-04, pvalue = 1e-04),
  compare = "unstandardized",
  sort = "none",
  showFixed = FALSE,
  showNS = TRUE,
  diffTest = FALSE
)

Arguments

m1

The first Mplus model to be compared. Generated by readModels, extractModelSummaries, or extractModelParameters.

m2

The second Mplus model to be compared.

show

What aspects of the models should be compared. Options are "all", "summaries", "equal", "diff", "pdiff", and "unique". See below for details.

equalityMargin

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.

compare

Which parameter estimates should be compared. Options are "unstandardized", "stdyx.standardized" "stdy.standardized", and "std.standardized".

sort

How to sort the output of parameter comparisons. Options are "none", "type", "alphabetical", and "maxDiff". See below for details.

showFixed

Whether to display fixed parameters in the output (identified where the est/se = 999.000, per Mplus convention). Default to FALSE.

showNS

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.

diffTest

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.

Value

No value is returned by this function. It is used to print model differences to the R console.

Details

The show parameter can be one or more of the following, which can be passed as a vector, such as c("equal", "pdiff").

show

"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"

Prints 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:

sort

"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).

Author

Michael Hallquist

Examples

# make me!!!