I am fairly new to RJAGS and I am crawling my way through writing model code and data formatting to perform some hierarchical modeling but I have hit some road bumps. I am trying to run the model
##########Example data
DATA
z = 20
y = 10
m = vector of 200 integers
n = vector of 200 integers
u = vector of 200 integers
But I receive the error
"Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, :
RUNTIME ERROR:
Compilation error on line 5.
Dimension mismatch in subset expression of m"
I have a hunch it has to do with my data classification more than my model (though my model might be off as well) but I am not sure. Any help would be hugely appreciated!
Last edit: Martyn Plummer 2015-07-03
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In your model, m, n, and u are matrices with z rows and y columns. When you supply them as data they should also be matrices with matching dimensions (i.e. z=20 rows and y=10 columns).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks a ton Martyn. I reformatted the data for n, m, & u into 20x10 matrices and it cleared up the dimension mismatch. Now onto model errors (I haven't changed the model code from the original post);
Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, :
Error in node u[1,1]
Observed node inconsistent with unobserved parents at initialization.
Try setting appropriate initial values.
I don't have any initial values set because I haven't needed them with my simpler models. I suspect the error has more to do with the model structure than the initial values but I am might be wrong.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think this is straightforward: The unobserved size parameter U[i,j] must be at least as big as the observed count u[i,j] so set initial values for U[i,j] accordingly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's the same issue as with the data. The variable U is a z by y matrix, so when you supply initial values from R, these have to be in the form of a matrix with the same dimensions. Currently you are supplying a vector.
Note that you cannot supply initial values for p because it is not a random variable. In your model, p is calculated deterministically from etaP.
logit(p[i,j])<- etaP[i,j]
You can supply initial values for etaP however, since this is a random variable:
etaU[i,j]~ dnorm(etaU1[i],tauU)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am fairly new to RJAGS and I am crawling my way through writing model code and data formatting to perform some hierarchical modeling but I have hit some road bumps. I am trying to run the model
But I receive the error
I have a hunch it has to do with my data classification more than my model (though my model might be off as well) but I am not sure. Any help would be hugely appreciated!
Last edit: Martyn Plummer 2015-07-03
In your model,
m
,n
, andu
are matrices withz
rows andy
columns. When you supply them as data they should also be matrices with matching dimensions (i.e.z=20
rows andy=10
columns).Thanks a ton Martyn. I reformatted the data for n, m, & u into 20x10 matrices and it cleared up the dimension mismatch. Now onto model errors (I haven't changed the model code from the original post);
I don't have any initial values set because I haven't needed them with my simpler models. I suspect the error has more to do with the model structure than the initial values but I am might be wrong.
I think this is straightforward: The unobserved size parameter
U[i,j]
must be at least as big as the observed countu[i,j]
so set initial values forU[i,j]
accordingly.I haven't had to set initial values before so I tried
and received
This should probably be straightforward but I am a JAGS novice and could use some advice.
Also, thanks again for your help so far Martyn.
It's the same issue as with the data. The variable
U
is az
byy
matrix, so when you supply initial values from R, these have to be in the form of a matrix with the same dimensions. Currently you are supplying a vector.Note that you cannot supply initial values for
p
because it is not a random variable. In your model,p
is calculated deterministically frometaP
.You can supply initial values for
etaP
however, since this is a random variable: