Bivariate Poisson model
Brought to you by:
martyn_plummer
I have found JAGSusing rjags does a lot of thengs that Winbugs could not but I hit a brick wall with this example
Can anyone spot my error
cat(
"model{
for(i in 1:n)
{
LH[i]<-eps[i]*AS[HT]*DS[AT]*HGA
LA[i]<-eps[i]*AS[AT]*DS[HT]
X[i,1] ~dpois(LH[i])
X[i,2] ~dpois(LA[i])
}
for(i in 1:n)
{
eps[i]~dgamma(1,1)
}
for(Z in 1:20)
{
AS[Z]~dgamma(1,1)
}
for(Z in 2:20)
{ DS[Z]~dgamma(1,1)
}
DS[1] <- 1
HGA~dgamma(1,1)
}
", file="BP.txt")
jags.data=NULL
jags.data$X=X
jags.data$n=n
jags.data$HT=HT
jags.data$AT=AT
jags3.m <- jags.model( file = "BP.txt", data=jags.data,
inits=list("AS"=rep(1,20),"DS"=c(NA,rep(1,19)),"eps"=rep(1,n)), n.chains=3, n.adapt=500 )
I get this error message
Error in jags.model(file = "BP.txt", data = jags.data, inits = list(AS = rep(1, :
RUNTIME ERROR:
Cannot insert node into LA[1]. Dimension mismatch
Anonymous
Diff:
We can't know for certain without seeing your data, but the most likely explanation is that in the expression
one of
AS[AT]
andDS[HT]
is a vector. Hence the expression evaluates to a vector and cannot be inserted into the scalar expression on the left hand side.Last edit: Martyn Plummer 2023-07-08