Menu

#15 Bivariate Poisson model

v1.0_(example)
open
nobody
None
1
2023-07-08
2023-07-07
Anonymous
No

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

Discussion

  • Martyn Plummer

    Martyn Plummer - 2023-07-08
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,7 @@
     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(
         &#34;model{
         for(i in 1:n)
    @@ -39,10 +40,12 @@
    
     jags3.m &lt;- jags.model( file = &#34;BP.txt&#34;, data=jags.data, 
                            inits=list(&#34;AS&#34;=rep(1,20),&#34;DS&#34;=c(NA,rep(1,19)),&#34;eps&#34;=rep(1,n)), n.chains=3, n.adapt=500 )
    -
    +~~~
    
     I get this error message
    
    +~~~
     Error in jags.model(file = &#34;BP.txt&#34;, data = jags.data, inits = list(AS = rep(1,  : 
       RUNTIME ERROR:
     Cannot insert node into LA[1]. Dimension mismatch
    +~~~
    
     
  • Martyn Plummer

    Martyn Plummer - 2023-07-08

    We can't know for certain without seeing your data, but the most likely explanation is that in the expression

    LA[i]<-eps[i]*AS[AT]*DS[HT]
    

    one of AS[AT] and DS[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

Anonymous
Anonymous

Add attachments
Cancel