Error: Illegal label 'Rand[data.ID,1]' detected in matrix 'A'. Square brackets must contain numeric literals when used inside of

Posted on
No user picture. Jean Joined: 11/10/2009

Hi,

I met with the error when I was running a Random Coefficient model:

Error: Illegal label 'Rand[data.ID,1]' detected in matrix 'A'. Square brackets must contain numeric literals when used inside of labels.

So, can we use the definition variable inside of the square brackets? Or maybe there is something wrong with my script. The related script is as below, and the variable ID is numeric (1:100).

-----------------------------------------------------------------------------------------
RandVals <- matrix(c(-0.2, -0.2), numSubjects, 2, byrow=TRUE)
...
...
...
mxMatrix("Full", nrow=numSubjects, ncol=2,
values=RandVals,
free=TRUE,
name="Rand"
),
mxMatrix("Full", 6, 6,
values=c( 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
-.2,-.2, 0, .1, .1, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
.1, .1, 0,-.2,-.2, 0),
labels=c( NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA,
"Rand[data.ID,1]","zetaX", NA,"gammaYX","gammadYX",NA,
NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA,
"gammaXY","gammadXY", NA, "Rand[data.ID,2]","zetaY", NA),
free=c( FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,
FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,
FALSE, TRUE, FALSE,TRUE, TRUE, FALSE,
FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,
FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,
TRUE, TRUE, FALSE,FALSE, TRUE, FALSE),
...
...
...

Replied on Sat, 02/19/2011 - 08:07
Picture of user. Ryne Joined: Jul 31, 2009

Hi Jean!

We had to change some of the capabilities of square bracket substitution because they caused a bug. See the following thread that shows how to implement a rand matrix much like yours in the new spec:

http://openmx.psyc.virginia.edu/thread/684

ryne

Replied on Sat, 02/19/2011 - 08:09
Picture of user. mspiegel Joined: Jul 31, 2009

Right. You can't use the definition variable inside the square brackets in a label. However, you can use the definition variable inside the square brackets in an MxAlgebra expression. Here is an example of how to this: http://openmx.psyc.virginia.edu/svn/tags/stable-1.0/models/passing/MultilevelUniRandomSlopeInt.R.

Replied on Sat, 02/19/2011 - 16:34
No user picture. Jean Joined: Nov 10, 2009

In reply to by mspiegel

Thank you so much! Now I know that the square brackets with definition variable could only be used in MxAlgebra. But, I would like to know, will we always use this way to specify model in the future? It seems not as straightforward as just using labels="Rand[data.ID, 1]"