You are here

Error in .subset(x, j) : invalid subscript type 'list'

4 posts / 0 new
Last post
svrieze's picture
Offline
Joined: 01/03/2010 - 20:52
Error in .subset(x, j) : invalid subscript type 'list'

Hello, not sure this is the best place for this question, but here goes.

I have a growth curve and I'm using the age at assessment as a definition variable in the factor loadings. There is missing data, both in the observed variables and the definition variables. It's an ACE twin model. The script is pasted below.

I am getting an error message I've never seen before:
------begin output-------
growthMalesFit <- mxRun(growthMales)
Running growthMales
Error in .subset(x, j) : invalid subscript type 'list'
------end output--------

Can anyone explain? Thanks for your time!
growthMales <- mxModel("growthMales",
mxModel("ACEm",
mxData(observed=agem, type="raw"),
mxMatrix("Lower",nf,nf, free=T, values=.8, byrow=TRUE, name="alm"),
mxMatrix("Lower",nf,nf, free=T, values=.8, byrow=TRUE, name="clm"),
mxMatrix("Lower",nf,nf, free=T, values=.8, byrow=TRUE, name="elm"),
mxData(observed=agem, type="raw"),
mxMatrix("Full",nrow=nv,ncol=nf, free=F, labels=
c("data.ONE", "data.age110",
"data.ONE", "data.age140",
"data.ONE", "data.age170",
"data.ONE", "data.age200",
"data.ONE", "data.age240",
"data.ONE", "data.age290"),
byrow=TRUE, name="flm0"),
mxMatrix("Full",nrow=nv,ncol=nf, free=F, labels=
c("data.ONE", "data.age111",
"data.ONE", "data.age141",
"data.ONE", "data.age171",
"data.ONE", "data.age201",
"data.ONE", "data.age241",
"data.ONE", "data.age291"),
byrow=TRUE, name="flm1"),
mxMatrix("Diag", nrow=nv,ncol=nv, free=T, values=.5, name="asm"),
mxMatrix("Diag", nrow=6,ncol=nv, free=T, values=.5, name="csm"),
mxMatrix("Diag", nrow=6,ncol=6, free=T, values=.5, name="esm"),
mxAlgebra( flm0 %&% (alm %% t(alm)) + asm %% t(asm), name="A0m"),
mxAlgebra( flm0 %&% (clm %% t(clm)) + csm %% t(csm), name="C0m"),
mxAlgebra( flm0 %&% (elm %% t(elm)) + esm %% t(esm), name="E0m"),
#
mxAlgebra( flm1 %&% (alm %% t(alm)) + asm %% t(asm), name="A1m"),
mxAlgebra( flm1 %&% (clm %% t(clm)) + csm %% t(csm), name="C1m"),
mxAlgebra( flm1 %&% (elm %% t(elm)) + esm %% t(esm), name="E1m"),
#
mxAlgebra( flm1 %% (alm %% t(alm)) %% t(flm0) + asm%%t(asm), name="A10m"),
mxAlgebra( flm1 %% (clm %% t(clm)) %% t(flm0) + csm%%t(csm), name="C10m"),
mxAlgebra( flm1 %% (elm %% t(elm)) %% t(flm0) + esm%%t(esm), name="E10m"),
#
mxAlgebra( flm0 %% (alm %% t(alm)) %% t(flm1) + asm%%t(asm), name="A01m"),
mxAlgebra( flm0 %% (clm %% t(clm)) %% t(flm1) + csm%%t(csm), name="C01m"),
mxAlgebra( flm0 %% (elm %% t(elm)) %% t(flm1) + esm%%t(esm), name="E01m"),
#
mxMatrix("Full",nrow=2,ncol=1, free=T, values=1, name="FacMeansm"),
mxAlgebra(flm0 %% FacMeansm, name="meansm0"),
mxAlgebra(flm1 %
% FacMeansm, name="meansm1"),
mxAlgebra(t(rbind(meansm0,meansm1)), name="expMeanm"),
#
mxAlgebra( rbind( cbind(A0m+C0m+E0m, A10m+C10m),
cbind(A01m+C01m, A1m+C1m+E1m)), name="MZexpCovarm"),
mxAlgebra( rbind( cbind(A0m+C0m+E0m, .5%x%A10m+C10m),
cbind(.5%x%A01m+C01m, A1m+C1m+E1m)), name="DZexpCovarm")
),
mxModel("DZm", mxData(observed=DZmales, type="raw"),
mxFIMLObjective(covariance="ACEm.DZexpCovarm", means="ACEm.expMeanm", dimnames=selVars)
),
mxModel("MZm", mxData(observed=MZmales, type="raw"),
mxFIMLObjective(covariance="ACEm.MZexpCovarm", means="ACEm.expMeanm", dimnames=selVars)
),
mxAlgebra(MZm.objective + DZm.objective, name="neg2sumllm"),
mxAlgebraObjective("neg2sumllm"),
independent=TRUE
)

growthMalesFit <- mxRun(growthMales)
-Scott

mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
The script in your message

The script in your message does not run. Several variables are undefined: agem, MZmales, DZmales, nv, nf, etc. If you'd like us to help you debug the script, then please fix it up. It's more convenient to include a script as an attachment to the forum post (click below on "File attachments") rather than copy/paste the script into the message. You don't need to include your original datasets in the modified script. Just create some fake data that will generate the same behavior in the mxRun() calll.

svrieze's picture
Offline
Joined: 01/03/2010 - 20:52
okay, here is the modified

okay, here is the modified script --- sorry for the inconvenience. I didn't simulate twin data for this ACE script, because independent data gave me the same error.

-Scott

mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
Ugh, sorry this is a bug. We

Ugh, sorry this is a bug. We have a corner case in our sorting of data where some operation is supposed to be returning a character(), and it's returning a list() in the case where all the elements are filtered out. I checked in the fix to our source code repository, I'll make OpenMx 1.0.6 this afternoon.
It is possible to run the script in the meantime if you add:

growthMales <- mxOption(growthMales, "No Sort Data", c("MZ", "DZ"))

However it will run slower because the data will not be sorted. Also, you can remove the independent=TRUE from the parent model. There are only benefits if submodels can be executed independently, the parent model does not benefit.