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