Thu, 08/18/2011 - 07:59

Hi,

I am a novice R user, who is committed to learning OpenMx for structural equation modeling for my research in psychology. I have been using the reference manual as a guide for setting up the syntax for the measurement model of my analysis. I have 19 manifest variables, and 7 latent constructs, for which I would like to obtain general fit indices, parameter estimates and modification indices. I tried to run the analysis using raw data that has less than 5% missingness. The following error messages were produced:

Error: unexpected ',' in "values=c(1,1,1),"

Error: unexpected ',' in "2", "ipv1", "ipv3", "ipv2", "ferc", "eerc", "cvs", "cvc", "cvp", "anx1", "anx2", "anx3", "pts1", "pts2", "pts3", "agg1", "agg2", "agg3"), latentVars = c("abuse", "partner", "community", "e"

Error: unexpected input in "anx1", "anx2", "anx3", "pts1", "pts2", "pts3", "agg1", "agg2", "agg3"), arrows=2, free=TRUE, values=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), labels=c("e1","e2","e3","e4","e5","e6", "e7","e8","

The syntax I used is pasted below:

manifests<- c("fm1", "fm2", "ipv1", "ipv3", "ipv2", "ferc", "eerc", "cvs", "cvc", "cvp", "anx1", "anx2", "anx3", "pts1", "pts2", "pts3", "agg1", "agg2", "agg3")

latents<-c("abuse", "partner", "community", "emotion", "anxiety", "aggression", "ptsd")

etv.cfa<-mxModel("exposure to violence measurement model", type="RAM", mxData (observed=etv, type= ╥raw╙), manifestVars=c(("fm1", "fm2", "ipv1", "ipv3", "ipv2", "ferc", "eerc", "cvs", "cvc", "cvp", "anx1", "anx2", "anx3", "pts1", "pts2", "pts3", "agg1", "agg2", "agg3"), latentVars = c("abuse", "partner", "community", "emotion", "anxiety", "aggression", "ptsd"), mxPath(from=c(("fm1", "fm2", "ipv1", "ipv3", "ipv2", "ferc", "eerc", "cvs", "cvc", "cvp", "anx1", "anx2", "anx3", "pts1", "pts2", "pts3", "agg1", "agg2", "agg3"), arrows=2, free=TRUE, values=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), labels=c("e1","e2","e3","e5","e4","e6", "e7","e8","e9","e10","e11","e12", "e13","e14","e15","e16","e17","e18", ╥e19╙), mxPath (from=c("abuse", "partner", "community", "emotion", "anxiety", "aggression", "ptsd"),

arrows=2,

all=TRUE,

free=TRUE,

values=c(1, .5,.5, .5, .5, .5, 1),

labels=c("phi1","phi2","phi3","phi4╙, "psi5",""psi6","psi7")

),

# factor loadings for abuse

mxPath(

from="abuse",

to=c("fm1", “fm2"),

arrows=1,

free=c(FALSE,TRUE),

values=c(1,1,1),

labels=c("l1","l2")

),

# factor loadings for partner violence

mxPath(

from="partner",

to=c("ipv1",╙ipv2", ╥ipv3╙),

arrows=1,

free=c(FALSE,TRUE, TRUE),

values=c(1,1,1),

labels=c("l3","l4", ╥l5╙)

),

# factor loadings for community violence

mxPath(

from="community",

to=c("cvc", “cvp", “cvs”),

arrows=1,

free=c(FALSE,TRUE, TRUE),

values=c(1,1,1),

labels=c("l6","l7", “l8”)

),

# factor loadings for emotion regulation

mxPath(

from="emotion",

to=c("ferc",”eerc"),

arrows=1,

free=c(FALSE,TRUE),

values=c(1,1),

labels=c("l9","l10")

),

# factor loadings for anxiety

mxPath(

from="anxiety",

to=c("anx1",╙anx2", “anx3”),

arrows=1,

free=c(FALSE,TRUE, TRUE),

values=c(1,1,1),

labels=c("l11","l12", “l13”)

),

# factor loadings for aggression

mxPath(

from="aggression",

to=c("agg1",”agg2", “agg3”),

arrows=1,

free=c(FALSE,TRUE, TRUE),

values=c(1,1,1),

labels=c("l14","l15", ╥l16╙)

),

# factor loadings for ptsd

mxPath(

from="ptsd",

to=c("pts1",╙pts2", ╥pts3╙),

arrows=1,

free=c(FALSE,TRUE, TRUE),

values=c(1,1,1),

labels=c("l17","l18", ╥l19╙)

),

#means

mxPath(

from="one",

to=c("fm1", "fm2", "ipv1", "ipv3", "ipv2", "ferc", "eerc", "cvs", "cvc", "cvp", "anx1", "anx2", "anx3", "pts1", "pts2", "pts3", "agg1", "agg2", "agg3", "abuse", "partner", "community", "emotion", "anxiety", "aggression", "ptsd"),

arrows=1,

free=c(TRUE,TRUE,TRUE,TRUE,TRUE,TRUE, TRUE,TRUE,TRUE,TRUE,TRUE,TRUE, TRUE,TRUE,TRUE,TRUE,TRUE,TRUE, TRUE, FALSE,FALSE, FALSE,FALSE, FALSE,FALSE, FALSE),

values=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0),

labels=c("meanfm1","meanfm2","meanipv1","meanipv2","meanipv3","meancvc","meancvp","meancvs","meanferc",╙meaneerc","meananx1","meananx2","meananx3","meanagg1","meanagg2","meanagg3","meanpts1","meanpts2", “meanpts3”, NA,NA,NA,NA,NA,NA,NA)

)

I would really appreciate any help.

Thanks in advance!

EsRoR

The following general suggestions will be helpful in debugging your script:

1. Include the script as an attachment ([filename.R]) to the OpenMx forums rather than in the message body.

2. Run each line of the script individually so that you may spot the first error and correct it. Repeat this process for each error in your script.

3. The "unexpected ','" message in R is usually due to an extra comma in function invocations.

4. Re-use variables that you have defined. So if you have defined

`manifests <- c("fm1", "fm2", "ipv1", ... )`

, then instead of retyping`c("fm1", "fm2", "ipv1", ... )`

use the variable`manifests`

.This is great. Thank you! I will address each of your points and follow-up shortly. Best