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.
The matrix line you copy in is fine, so it won't be stopping on this:
It's likely a line earlier in the model which has a trailing comma, or perhaps an unclosed quote?
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")
)
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.
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
Thanks.