Not sure if this is by deisgn/necessity or something we can alter.
It is illegal to create variables other than mxModel components inside an mxModel. Therefore things like this fail (with errors that will be cryptic to users):
lboundList = c(rep(-3,times=nVar), rep(.0001,times=nVar*(maxThresholds-1))),
mxMatrix("Full", maxThresholds, nVar, free=T, lbound = lboundList, values=.5, name="baseAndIncrements"),
Because OpenMx tries to add the items of lboundList to the model:
Error: Cannot add the following item(s) into the model: -3Cannot add the following item(s) into the model: -3...
This is fine:
mxMatrix("Full", maxThresholds, nVar, free=T, lbound =c(rep(-3,times=nVar), rep(.0001,times=nVar*(maxThresholds-1))), values=.5, name="baseAndIncrements"),
But clumsy. Is there a way to say "make this in the global space so I can use it shortly", or do we have to make all our variables outside the model, then use them?
#1
Log in or register to post comments
#2
Perhaps it is just that OpenMx gets you in the habit of putting commas behind everything because you are inside a function... but it never occured to me that it would then be ok to sneak in variable definitions as statements between comma-delimitted parameters, esp. given the error.
I won't make the mistake again, but I imagine some users will follow in my footsteps...
Oh well.
t
Log in or register to post comments
#3
mxModel('name', stuff = c(1,2,3,4,5), mxMatrix(values = stuff)).
However, the "=" operator in R serves two purposes. It can be either the assignment operator "<-" or the function call parameter operator. In this context, the "=" operator is interpreted the second way. Like I said, I can't be sure that you were trying to do that. But I'm trying to guess as to why you had commas in between the two expressions.
Log in or register to post comments
#4
mxModel('name',
stuff = c(1,2,3,4,5),
mxMatrix(values = stuff)
).
OK: So in this situation, one needs to do assignment. That would explain why I had felt this used to work: will have been using <- previously.
Never seen a case before where <- and = had different outcomes. Now I have ;-)
Log in or register to post comments
#5
Log in or register to post comments