Attachment | Size |
---|---|
MVcor3var_ IP_CP_OpenMx.R | 55.19 KB |
Hi, everyone.
I was fitting a multivariate model with a general script. The commands didn't have errors. After I mxRun() and summary() my model, it quickly presented the summary. But the problem was that there were no -2ll, AIC, BIC, or any other fitting results, though the number of observations was rightly showed. And it seemed just summarized the dataset, like the min, max, and mean of every variables of the dataset, not the model fit. I guess the values of the variables were not input to the model. But why?
I attached the example script written by Rijsdijk here. Every steps I did were following the very script.
I am looking forward for your reply. Thank you in advance.
It sounds like you applied the summary() function to the unfitted model and not the fitted model. If you attach a copy of the script you executed, it would give us more information to determine what is happening.
my script
just had a quick look, but down the bottom of the main model, you have managed to put the objective for your outer model into the OS model...
should look like this:
<
pre>
mxAlgebra(rbind(cbind(Am/Vm,Cm/Vm,Em/Vm),cbind(Af/Vf,Cf/Vf,Ef/Vf)), name="VarComp"),
mxModel("MZm", mxData(mzmData,"raw" ), mxFIMLObjective("ACE.expCovMZm","ACE.expMeanm", dimnames=selVars )),
mxModel("DZm", mxData(dzmData,"raw" ), mxFIMLObjective("ACE.expCovDZm","ACE.expMeanm", dimnames=selVars )),
mxModel("MZf", mxData(mzfData,"raw" ), mxFIMLObjective("ACE.expCovMZf","ACE.expMeanf", dimnames=selVars )),
mxModel("DZf", mxData(dzfData,"raw" ), mxFIMLObjective("ACE.expCovDZf","ACE.expMeanf", dimnames=selVars )),
mxModel("OS", mxData(dzosData,"raw"), mxFIMLObjective("ACE.expCovOS" ,"ACE.expMeanOs", dimnames=selVars )),
mxAlgebra(MZm.objective + DZm.objective + MZf.objective + DZf.objective + OS.objective, name="modelfit" ),
mxAlgebraObjective("modelfit"),
mxCI (c('ACE.VarComp'))
)
)
Sorry, I am not sure that I understand your explaination. What's the outer model?
I did not find difference between your script and mine. Though I copied your script to run, and got the same result.
The short version: Move one of the parentheses from the last line before the
.
This line is just before you start adding MZ and DZ models.
The longer version: In this script, you first create a container model, called ACEsex. Then you build a model inside that, called ACE, and four models inside that, called MZm, DZm, etc. More important than that, the container model ACEsex has no objective function. You can check this by looking at the raw model itself (you stored it in ACEsexModel, so just type
ACEsexModel
at the R command prompt). Notice that it has one object (ACE) in its @submodels slot, and only NULL in its @objective slot.Now move the parenthesis, and run it again. The paren that we're moving closes the
mxModel("ACE" ..
. That means that the MZm, etc. models will now end up in the container model (ACEsex) rather than the child model (ACE). More importantly, the two lines that follow, the mxAlgebra() and the mxAlgebraObjective(), will be part of the container model (ACEsex). Go ahead and look at ACEsex again. Notice that it now has several submodels and a non-NULL objective function.Unless you have independent child models, only the objective function of the outermost model (the container model, in this case ACEsex) will be minimized.
I appreciate all of you for your patience and explainations. I knew the ACE model was nested in the ACEsex model, but, I have to say, I misunderstood the word "outer".
I will treat the parenthesis more carefully. And thanks again.