You are here

syntax problem with saturated model

6 posts / 0 new
Last post
cvanhulle's picture
Offline
Joined: 05/07/2010 - 17:28
syntax problem with saturated model

Hi, I modified a twin model so that I could look at the saturated model. The twin model runs fine, but I get the following error with the saturated model

Error in mxModel("SAT", mxMatrix(type = "Full", nrow = ntv, ncol = ntv, :
argument is missing, with no default

For some reason R stops reading after ncol=ntv. The rest of the syntax is below:

     mxMatrix( type="Full", nrow=ntv, ncol=ntv, free=TRUE, values=.6,  label=c("dz11","dz21","dz22"), name="MZL" ),

It's nearly identical to the twin model syntax which runs fine, so I can't imagine why I keep getting the above error. Many thanks for your help.

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
trailing comma somewhere

The matrix line you copy in is fine, so it won't be stopping on this:

Error in mxModel("SAT", 
   mxMatrix( type="Full", nrow=ntv, ncol=ntv, free=TRUE, values=.6, label=c("dz11","dz21","dz22"), name="MZL" )
)

It's likely a line earlier in the model which has a trailing comma, or perhaps an unclosed quote?

cvanhulle's picture
Offline
Joined: 05/07/2010 - 17:28
no missing commas

I thought of that first, but I can't find any missing quotes or trailing commas or missing commas, etc. Here's the full code.

SATmodel <- mxModel("univSAT",
mxModel("SAT",
mxMatrix( type="Lower", nrow=ntv, ncol=ntv, free=TRUE, values=.6, name="MZL" ),
mxMatrix( type="Lower", nrow=ntv, ncol=ntv, free=TRUE, values=.6, name="DZL" ),
mxAlgebra( expression=MZL %% t(MZL), name="expCovMZm" ),
mxAlgebra( expression=DZL %
% t(DZL), name="expCovDZm" ),
mxMatrix( type="Full", nrow=1, ncol=nv, free=TRUE, values= 2.1, label="meanm", name="Mm" ),
mxAlgebra( expression= cbind(Mm,Mm), name="expMeanZm"),
),
mxModel("MZm",
mxData( observed=mzmDataP, type="raw" ),
mxFIMLObjective( covariance="SAT.expCovMZm", means="SAT.expMeanZm", dimnames=selVars )
),
mxModel("DZm",
mxData( observed=dzmDataP, type="raw" ),
mxFIMLObjective( covariance="SAT.expCovDZm", means="SAT.expMeanZm", dimnames=selVars )
),
mxAlgebra( expression=MZm.objective + DZm.objective, name="2sumll" ),
mxAlgebraObjective("2sumll")
)

RobK's picture
Offline
Joined: 04/19/2011 - 21:00
Extra comma

I think this is the problematic line:
mxAlgebra( expression= cbind(Mm,Mm), name="expMeanZm"),
R is expecting an additional argument to mxModel() after the comma, but there isn't one there. Try deleting the comma and see if it works.

Edit: the comma at the end of the line, that is.

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
commas lurk everywhere :-)

YIP: if you have a good text editor, looking for a pattern like ")[\w\n]?,[\w\n]?)" is a good time saver for trailing commas that are hard to spot visually

cvanhulle's picture
Offline
Joined: 05/07/2010 - 17:28
that did the trick

Thanks.