what's wrong with my data?

Posted on
No user picture. userzht Joined: 02/19/2011
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.

Replied on Sat, 04/09/2011 - 22:05
Picture of user. mspiegel Joined: 07/31/2009

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.
Replied on Sun, 04/10/2011 - 07:29
Picture of user. tbates Joined: 07/31/2009

In reply to by userzht

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:

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'))
)
)
Replied on Sun, 04/10/2011 - 11:24
Picture of user. tbrick Joined: 07/31/2009

In reply to by userzht

The short version: Move one of the parentheses from the last line before the mxRun() command to here:
mxAlgebra( expression=rbind(cbind(Am/Vm,Cm/Vm,Em/Vm),cbind(Af/Vf,Cf/Vf,Ef/Vf)), name="VarComp")), # Note second paren I added.

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.

Replied on Sun, 04/10/2011 - 23:07
No user picture. userzht Joined: 02/19/2011

In reply to by tbrick

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.