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),
...
...
...
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
Thank you, Ryne! This helps me a lot! No error any more.
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.
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]"