| mxCompare {OpenMx} | R Documentation |
Compare the fit of one or more models to a base model. The output is a table with one row per model comparison.
mxCompare(base, comparison, ..., all = FALSE)
base |
A MxModel object or list of MxModel objects. |
comparison |
A MxModel object or list of MxModel objects. |
... |
Not used. Forces remaining arguments to be specified by name. |
all |
A boolean value on whether to compare all bases with all comparisons. |
Use options('digits' = N) to set the minimum number of significant digits to be printed in values. The following columns appear in the output:
Name of the base model
Name of the comparison model
Estimated parameters of the comparison model
Minus 2*log-likelihood of the comparison model
Degrees in freedom of the comparison model
Akaike's Information Criterion for the comparison model
Change in minus 2*log-likelihood
Change in degrees of freedom
Significance level of the change in fitness function
mxModel; options (use options('mxOptions') to see all the OpenMx-specific options)
data(demoOneFactor)
manifests <- names(demoOneFactor)
latents <- c("G1")
model1 <- mxModel("One Factor", type="RAM",
manifestVars = manifests,
latentVars = latents,
mxPath(from = latents, to=manifests),
mxPath(from = manifests, arrows = 2),
mxPath(from = latents, arrows = 2, free = FALSE, values = 1.0),
mxData(cov(demoOneFactor), type = "cov", numObs = 500)
)
fit1 <- mxRun(model1)
latents <- c("G1", "G2")
model2 <- mxModel(name="Two Factor", type="RAM",
manifestVars = manifests,
latentVars = latents,
mxPath(from = latents[1], to=manifests[1:3]),
mxPath(from = latents[2], to=manifests[4:5]),
mxPath(from = manifests, arrows = 2),
mxPath(from = latents, arrows = 2, free = FALSE, values = 1.0),
mxData(cov(demoOneFactor), type = "cov", numObs=500)
)
fit2 <- mxRun(model2)
mxCompare(fit1, c(fit2))
# vary precision of the output (no effect for this example)
oldPrecision = as.numeric(options('digits'))
options('digits' = 3)
mxCompare(fit1, c(fit2))
options('digits' = oldPrecision)