3 Factor CFA in Mplus and OpenMX, what's missing?
Posted on
smcquillin
Joined: 08/28/2009
Attachment | Size |
---|---|
open_mx.txt | 11.29 KB |
mplus_syntax.txt | 8.93 KB |
Greetings,
I'm trying to transfer a 3 factor CFA from Mplus to OpenMX, and I believe I'm missing something. I've attached the syntax and output from both; however, the primary difference is the notable absence of CFI, TLI, and Chi-Squared in OpemMx. I remember seeing another post re: missing CFI/TLI, but couldn't seem to find it at second glance. I'm pretty certain this is an operator error, rather than program differences, because I have transferred a similar model in the past. Thanks for any help,
Sam
The biggest difference I can
The missing Chi-Squared in OpenMx is the result of using raw data full-information maximum likelihood (FIML) for handling missing data. The missing CFI, TLI, and RMSEA are fallout from the missing Chi-Squared. OpenMx does not automatically report Chi-squared when using raw data because the Chi-Squared value is the difference between the -2 log likelihood of the fitted model (that is, the model you specified) and the -2 log likelihood of the saturated model.
When you have covariance data, the saturated model -2 log likelihood is very simple to calculate. When you have raw data, it is potentially as time-consuming as fitting the model specified by the user.
I know there was a feature request for a helper function to construct saturated models: http://openmx.psyc.virginia.edu/thread/979
But I do not know if that was filled.
Finally, if you have a saturated model that you fit named MySaturatedModel, then
summary(MyModel, SaturatedLikelihood=MySaturatedModel)
should give the Chi-Squared, TLI, CFI, and RMSEA.
Best,
Mike
Log in or register to post comments
In reply to The biggest difference I can by mhunter
This is helpful. I freely
Sam
Log in or register to post comments
In reply to This is helpful. I freely by smcquillin
I have a very similar
Also, does Open MX have an MLR estimator like MPLUS?
Thanks in advance for your help!
Log in or register to post comments
In reply to I have a very similar by JVaske
column order?
So the fixed factor one has happened, but is applied to the wrong variable.
But I can't replicate: Here's version that runs properly, even with jumbled data columns, can you try?
library(MASS)
manifests = c("task", "swear", "impuls", "lsc")
myCov = c(
1, .3, .3, .3,
.3, 1, .3, .3,
.3, .3, 1, .3,
.3, .3, .3, 1)
myCov = matrix(nrow = 4, byrow = T, myCov);
mydata = MASS::mvrnorm (n = 100, mu = rep(0,4), Sigma = myCov);
# jumble column order
mydata = data.frame(mydata); names(mydata) <- manifests[c(2:3,1,4)];
oneFactorModel <- mxModel("Common Factor Model Path Specification", type = "RAM",
manifestVars = manifests,
latentVars = "F1",
# latent and residual variances
mxPath(from = "F1", arrows = 2, free = T, values = 1, labels = "varF1"),
mxPath(from = manifests, arrows = 2, free = T, values = 1, labels = paste0("e", 1:4)),
# factor loadings (first loading fixed @ 1)
mxPath(from="F1", to = manifests, arrows = 1, free = c(F,T,T,T), values = 1, labels = paste0("l", 1:4)),
# means
mxPath(from = "one", to = "F1", arrows = 1, free = F, values = 0, labels = "meanF1"),
mxPath(from = "one", to = manifests, arrows = 1, free = T, values = 1, labels = paste0("meanx", 1:4)),
mxData(observed = mydata, type = "raw")
)
oneFactorFit <- mxRun(oneFactorModel)
summary(oneFactorFit)
oneFactorFit@output
Log in or register to post comments
In reply to column order? by tbates
Clear Workspace?
I can't seem to replicate the error on my machine either.
It's possible there's something hanging around in your workspace from a previous run that isn't being replaced properly because of the typos in the posted script. Try clearing your workspace (the broom icon in the corner of the Workspace section in RStudio) and running the script again. Note that clearing your workspace will remove any variables/history/previous fits that you have saved.
If that doesn't work, maybe it's a specific problem with the way the data is structured? I can't imagine what that problem might be, but it's worth checking.
Would you be willing to either post your data or run the fakeData command (available here ) on your data and post the simulated data? If you simulate data, please try the model once on the simulated data to make sure the path names still don't match.
Log in or register to post comments
In reply to Clear Workspace? by tbrick
Hi,Thanks so much for your
Thanks so much for your quick responses! Yes this was a total user error. I wasn't aware that the data needed to be organized/structured in the same manner it was to be analyzed (unless you modified the code at the beginning of the syntax). Once I moved the "task" variable to be the first variable, it was constrained to 1.00 and all of the other parameter estimates matched those from MPLUS.
Also, does Open MX have a maximum likelihood estimator with robust standard errors (in case a continuous variable is not normally distributed)? I looked through the user manual but did not see anything on the topic.
Thanks again for your help!
Log in or register to post comments
In reply to Hi,Thanks so much for your by JVaske
OpenMx doesn't/shouldn't care about order of data are frame
Can you please let us know what version of OpenMx (and perhaps R) you are using?
mxVersion()
[1] "1.3.2-2301"
version$version.string
[1] "R version 2.15.2 (2012-10-26)"
We have really FIML standard errors via mxCI()
No WLS as yet...
Log in or register to post comments
In reply to OpenMx doesn't/shouldn't care about order of data are frame by tbates
Hi Tim, I moved the variable
I moved the variable back to it's original location, re-ran the analyses, and received the same results as MPLUS--perhaps the other Tim was correct that something was hanging around in my workspace and that caused my estimates to be different.
As for my versions:
> mxVersion()
[1] "1.3.2-2301"
>
> version$version.string
[1] "R version 2.15.0 (2012-03-30)"
Log in or register to post comments
In reply to Hi Tim, I moved the variable by JVaske
cleanliness (of the environment) is next to godliness :-)
rm(list=ls()) can be a good help.
Log in or register to post comments
MLR
I am new to OpenMx and think one can learn a lot from using it.
Generally I use the lavaan package in R to estimate SEM models.
Can someone tell me whether OpenMx does have an MLR estimator? Or where I can look up how the ML estimator is specified in the mxFitFunctionML?
Any help would be appreciated!
Kind regards
Log in or register to post comments
?imxRobustSE
mxFitFunctionML()
in your model, and then runningimxRobustSE()
on the fitted model to get robust standard errors. See the help page for details: [?imxRobustSE](https://search.r-project.org/CRAN/refmans/OpenMx/html/imxRobustSE.html)Log in or register to post comments
Thank you
Log in or register to post comments