unexpected string constant error message in mxModel

Posted on
No user picture. rranne2@uic.edu Joined: 12/10/2018
Hi there,

I'm looking at how neuroticism ("per_neurot_y1f") predicts later change in symptoms of anxiety (from Time 1 to Time 3). I'm not sure why I'm getting this error message about this particular string of my model. Here's my code.

manifests <- c("Time1newanxiety", "Time3anxiety", "per_neurot_y1f")
latents<-"F1"

myModelstep2<-mxModel(model="Step two", type="RAM", manifestVars=manifests, latentVars=latents,
mxPath(from="Time1newanxiety", to="Time3anxiety", arrows=1, free=FALSE, values=1, labels=c("L1")),
mxPath(from = "F1", to = "Time3anxiety", arrows=1, free=FALSE , values=1, labels=c("L2")),
mxPath(from ="Time1newanxiety", to = "F1", arrows = 2, free=TRUE, values = .4, labels=c("L3")),
mxPath(from = "per_neurot_y1f", to "Time1newanxiety", arrows=2, free=TRUE, values=.6, labels=c("L4")), mxPath(from = "per_neurot_y1f", to "F1", arrows = 1, free=TRUE, values = .3, labels=c("L5")),
mxPath(from = "F1", to = "F1", arrows = 2, free=TRUE, values = 1, labels=c("e1")),
mxPath(from = "Time1newanxiety", to = "Time1newanxiety", arrows=2, free=TRUE, values = .8, labels=c("e2")),
mxPath(from "per_neurot_y1f", to "per_neurot_y1f", arrows = 2, free=TRUE, values = 1, labels=c("e3")),
mxPath(from = "one", to = "Time1newanxiety", arrows=1, free=TRUE, values = 7.36, labels=c("manxiety1")),
mxPath(from = "one", to = "F1", arrows=1, free=TRUE, values = .1, labels=c("mchangeanxiety")),
mxPath(from = "one", to "per_neurot_y1f", arrows = 1, free=TRUE, values = 8.83, labels=c("mneurot")),
mxData(observed=mydata3, type="raw"))

Error: unexpected string constant in "labels=c("L1")), mxPath(from = "F1", to = "Time3anxiety", arrows=1, free=FALSE , values=1, labels=c("L2")), mxPath(from ="Time1newanxiety", to = "F1", arrows = 2, free=TRUE, values = .4, label"

I'm not seeing how that string is really that different from any other part of the mode. I was able to run a more simple version of this model just creating a latent difference score of change in anxiety from Time 1 to Time 3, without adding "per_neurot_y1f," so I don't understand why the same code from that old model now is a problem.

Any help would be greatly appreciated!

Replied on Tue, 12/18/2018 - 09:59
No user picture. rranne2@uic.edu Joined: 12/10/2018

The L5 line wasn't indented so you can't see it in the original post. Here's a better formatted version

myModelstep2<-mxModel(model="Step two", type="RAM", manifestVars=manifests, latentVars=latents,
mxPath(from="Time1newanxiety", to="Time3anxiety", arrows=1, free=FALSE, values=1, labels=c("L1")),
mxPath(from = "F1", to = "Time3anxiety", arrows=1, free=FALSE , values=1, labels=c("L2")),
mxPath(from ="Time1newanxiety", to = "F1", arrows = 2, free=TRUE, values = .4, labels=c("L3")),
mxPath(from = "per_neurot_y1f", to "Time1newanxiety", arrows=2, free=TRUE, values=.6, labels=c("L4")),
mxPath(from = "per_neurot_y1f", to "F1", arrows = 1, free=TRUE, values = .3, labels=c("L5")),
mxPath(from = "F1", to = "F1", arrows = 2, free=TRUE, values = 1, labels=c("e1")),
mxPath(from = "Time1newanxiety", to = "Time1newanxiety", arrows=2, free=TRUE, values = .8, labels=c("e2")),
mxPath(from "per_neurot_y1f", to "per_neurot_y1f", arrows = 2, free=TRUE, values = 1, labels=c("e3")),
mxPath(from = "one", to = "Time1newanxiety", arrows=1, free=TRUE, values = 7.36, labels=c("manxiety1")),
mxPath(from = "one", to = "F1", arrows=1, free=TRUE, values = .1, labels=c("mchangeanxiety")),
mxPath(from = "one", to "per_neurot_y1f", arrows = 1, free=TRUE, values = 8.83, labels=c("mneurot")),
mxData(observed=mydata3, type="raw"))

Replied on Tue, 12/18/2018 - 10:04
Picture of user. AdminRobK Joined: 01/24/2014

There are four calls to `mxPath()` in that syntax that don't have an equals sign between named argument `to` and its intended value.
Replied on Tue, 12/18/2018 - 10:07
Picture of user. AdminRobK Joined: 01/24/2014

In reply to by AdminRobK

There's also an equals sign missing after `from` in one of the calls as well.
Replied on Tue, 12/18/2018 - 10:05
Picture of user. jpritikin Joined: 05/23/2012

You're missing the '=' after 'to'. You have to "Time1newanxiety" instead of to="Time1newanxiety"
Replied on Tue, 12/18/2018 - 15:41
No user picture. rranne2@uic.edu Joined: 12/10/2018

Thank you! Whoops that was silly of me! I was so focused on the part that the error message pointed my attention to that I forgot to double check the rest of my code.