During compilation I am getting an error which says- "Multivariate distribution must have more than one component", I couldn't get much info about this error. Anyone having any idea how to solve this problem please share. Thanks.
model {
for(i in 1:n)
{ for(j in 1:J)
{ log(mu[i,j]) <- beta1[j]*x1[i] + beta2[j]*x2[i] + b[i,j]
}
for(k in 1:J) { y[i,k]~ dpois(mu[i,1:J])
}}
# PRIORS
for (i in 1:n) {
for(k in 1:J) {
b[i,k]<- 1
}}
beta1[1]<- beta3[1,1]
beta1[2]<- beta3[2,2]
beta2[1]<- beta4[1,1]
beta2[2]<- beta4[2,2]
for (j in 1:J) {beta3[j,j]~ dmnorm(zero[], B[,]);
beta4[j,j]~ dmnorm(zero[], B[,]) }
for(i in 1:J)
{ for (j in 1:J)
{ B[i,j] <- 0.01*equals(i,j);
}}
for (i in 1:J) { zero[i] <- 0;}
}
#Data:
list(n=3, J=2)
#Data:
y[ ,1] x1[] x2[] y[,2]
0 9.91 8.34 1
3 10.48 10.14 79
0 10.31 9.42 40
You would need to do something like this:
This will create a 2 by 2 matrix of model coefficients. However, you are only using the diagonal elements of
beta3andbeta4in your model which is a little strange.