Hi Nimble community,
Looks like matrix math on 3-D arrays is not allowed, or at least not in the context I'm aiming for. I'm mostly writing this thread so that when I next encounter this error I will be able to find it on the NIMBLE google group and remember my solution.
Is the work around just to write a NIMBLE function that takes the 3D object, turns it into 2D, does some math, then stores it?
Here's the problem area in my code:
log(psi[i,k,t]) <- X2[i,1:5,t] %*% betaVector2[1:5,k]
In theory, this should just be calculating a 1 row, 5 column matrix multiplied by a 5 row, 1 column matrix at each time step, but seems that NIMBLE says no.
Here's the compiling output:
Warning, in eigenizing model_psi[getNodeFunctionIndexedInfo(ARG1_INDEXEDNODEINFO__,2), getNodeFunctionIndexedInfo(ARG1_INDEXEDNODEINFO__,1), getNodeFunctionIndexedInfo(ARG1_INDEXEDNODEINFO__,3)] the [ is still there but nDim is not 0 (not a scalar).
Error : Cannot do math with arrays that have more than 2 dimensions.
This occurred for: model_psi
This was part of the call: model_psi[getNodeFunctionIndexedInfo(ARG1_INDEXEDNODEINFO__,2), getNodeFunctionIndexedInfo(ARG1_INDEXEDNODEINFO__,1), getNodeFunctionIndexedInfo(ARG1_INDEXEDNODEINFO__,3)]
Error: There is some problem at the Eigen processing step for this code:
{
model$psi[getNodeFunctionIndexedInfo(INDEXEDNODEINFO_, 2), getNodeFunctionIndexedInfo(INDEXEDNODEINFO_, 1), getNodeFunctionIndexedInfo(INDEXEDNODEINFO_, 3)] <<- exp(model$X2[getNodeFunctionIndexedInfo(INDEXEDNODEINFO_, 2), 1:5, getNodeFunctionIndexedInfo(INDEXEDNODEINFO_, 3)] %*% model$betaVector2[1:5, getNodeFunctionIndexedInfo(INDEXEDNODEINFO_, 1)])
}
Many thanks!
Heather Gaya