You are here

Error in MZ and DZ Expected Matrices

4 posts / 0 new
Last post
newsomjr's picture
Offline
Joined: 10/13/2009 - 01:27
Error in MZ and DZ Expected Matrices
AttachmentSize
Binary Data LGC Script.R8.65 KB

I am working with the script I received at the workshop in Boulder earlier this year. I have altered the original script slightly to fit my data, but I am getting the following error messages in this section of my script:

#MZ AND DZ EXPECTED MATRICES
>
> # Algebra for expected Int & Slope means + sex effects (betas) for MZs
> mxModel("MZ",
+ mxData(data.frame(mzData,mzDefs), type="raw",) # Requests MZ definition variables: GENDER_1 & GENDER_2
+ mxMatrix( type="Full", nrow=1, ncol=1, free=FALSE, labels=c("data.GENDER_1"), name="GENDER_1"), # Selects GENDER_1 from mzDefs
Error: unexpected symbol in:
" mxData(data.frame(mzData,mzDefs), type="raw",) # Requests MZ definition variables: GENDER_1 & GENDER_2
mxMatrix"
> mxMatrix( type="Full", nrow=1, ncol=1, free=FALSE, labels=c("data.GENDER_2"), name="GENDER_2"), # Selects GENDER_2 from mzDefs
Error: unexpected ',' in " mxMatrix( type="Full", nrow=1, ncol=1, free=FALSE, labels=c("data.GENDER_2"), name="GENDER_2"),"
> #1X1 MATRIX OF THE TWINS SEX ABOVE FOR TWIN 1S SEX AND TWIN 2S SEX
> # Classic Mx means model=(F * (M+(sex_t1@Betas)))' | (F * (M+(sex_t2@Betas)))'
> mxAlgebra(expression=cbind( t(ACE.F %% ( ACE.Mean + (GENDER_1 %x% ACE.Beta))),
+ t(ACE.F %
% ( ACE.Mean + (GENDER_2 %x% ACE.Beta))) ), name="expMean"),
Error: unexpected ',' in:
"mxAlgebra(expression=cbind( t(ACE.F %% ( ACE.Mean + (GENDER_1 %x% ACE.Beta))),
t(ACE.F %
% ( ACE.Mean + (GENDER_2 %x% ACE.Beta))) ), name="expMean"),"
> mxFIMLObjective( covariance="ACE.expCovMZ", means="expMean", dimnames=selVars ) ),
Error: unexpected ')' in " mxFIMLObjective( covariance="ACE.expCovMZ", means="expMean", dimnames=selVars ) )"

I have attached the full script, and would greatly appreciate any assistance. Thanks very much!
Jamie

mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
Hi, You have a function call

Hi,

You have a function call that has a trailing comma with no function argument after the comma.

mxData(data.frame(mzData,mzDefs), type="raw",)

Delete the trailing comma and that syntax error will be fixed.

neale's picture
Offline
Joined: 07/31/2009 - 15:14
This is such a popular error

This is such a popular error with new R and OpenMx users I almost wonder whether we should have a utility to scan for
",). In bigger scripts it will be more tedious for even experts like mspiegel to spot. And this leads us to rethinking the OpenMx scripting style used in our documentation, which (as Greg Carey pointed out at a meeting in Seoul this year) makes debugging difficult. On the other hand, it does have the advantage of bypassing the pass-by-value issue, so at least we're not having to answer questions of that ilk.

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
So I guess we are not being

So I guess we are not being pre-parsed by ourselves, just parsed in R...

Maybe someone can suggest to the R core team that they make their error more helpful... i.e., mention that , ) might be a mistake not a missing parameter?