require(OpenMx)
data(demoOneFactor)
manifests <- names(demoOneFactor)
latents <- c("G")
factorModel <- mxModel("OneFactor", type = "RAM",
manifestVars = manifests, latentVars = latents,
mxPath(from = latents, to=manifests, values = diag(var(demoOneFactor))*.2),
mxPath(from = manifests, arrows = 2, values = diag(var(demoOneFactor))*.8),
mxPath(from = latents, arrows = 2, free = FALSE, values = 1),
mxData(cov(demoOneFactor), type = "cov", numObs = 500)
)
factorRun <- mxRun(factorModel)
factorSat <- mxRefModels(factorRun, run=TRUE)
summary(factorRun)
summary(factorRun, refModels=factorSat)
# A raw-data example where using mxRefModels adds fit indices
# \donttest{
m1 <- mxModel("OneFactor", type = "RAM",
manifestVars = manifests, latentVars = latents,
mxPath(latents, to=manifests, values = diag(var(demoOneFactor))*.2),
mxPath(manifests, arrows = 2, values = diag(var(demoOneFactor))*.8),
mxPath(latents, arrows = 2, free = FALSE, values = 1),
mxPath("one", to = latents, free = FALSE, values = 0),
mxPath("one", to = manifests, values = 0),
mxData(demoOneFactor, type = "raw")
)
m1 <- mxRun(m1)
summary(m1) # CFI, TLI, RMSEA missing
summary(m1, refModels=mxRefModels(m1, run = TRUE))
# }
Run the code above in your browser using DataLab