You are here

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

5 posts / 0 new
Last post
Jean's picture
Offline
Joined: 11/10/2009 - 15:20
Error: Illegal label 'Rand[data.ID,1]' detected in matrix 'A'. Square brackets must contain numeric literals when used inside of

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 ...
...
...
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),
...
...
...

Ryne's picture
Offline
Joined: 07/31/2009 - 15:12
Hi Jean! We had to change

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

Jean's picture
Offline
Joined: 11/10/2009 - 15:20
Thank you, Ryne! This helps

Thank you, Ryne! This helps me a lot! No error any more.

mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
Right. You can't use the

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.

Jean's picture
Offline
Joined: 11/10/2009 - 15:20
Thank you so much! Now I know

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]"

Log in or register to post comments