model { # Likelihood for (i in 1:Nareas) { for (k in 1:Ndiseases) { O[i, k] ~ dpois(lambda[i, k]) log(lambda[i, k]) <- log(E[i, k]) + mu[k] + Theta[i,k] RR[i,k] <- exp(mu[k] + Theta[i,k]) } } for (i in 1:Nareas){ for(k in 1:Ndiseases){ Theta[i,k]<-inprod2(tPhi[,i],M[,k]) } } #### Matrix of spatially correlated random effects: #### if M is a square matrix define Nsp (Number of spatial underlying patterns) as Ndiseases for(j in 1:Nsp){ Spatial[j,1:Nareas]~car.normal(adj[],weights[],num[],1) for (i in 1:Nareas){ Het[j,i]~dnorm(0,1) tPhi[j, i]<-Spatial[j,i] } } for (j in (Nsp+1):(2*Nsp)){ for (i in 1:Nareas){ tPhi[j,i]<-Het[(j-Nsp),i] } } #### M-matrix for (i in 1:(2*Nsp)){ for (j in 1:Ndiseases){ ### This corresponds to the fixed effects model M[i,j]~dflat() ### In case of implementing the random effects model comment the previous line ### and uncomment the next one ###M[i,j] ~ dnorm(0,prec) } } ###In case of implementing the random effects model uncomment the next two lines ###prec<-pow(sdstruct,-2) ###sdstruct~dunif(0,100) # Other priors for (k in 1:Ndiseases){ mu[k] ~ dflat() } }