model{ for(i in 1:nmuni){ for(j in 1:nperiods){ Obs[j,i]~dpois(mu[j,i]) #Modelling of the mean for every municipality and period log(mu[j,i])<-log(Exp[j,i])+mediainter+inter[j]+het[i]+spat[i] #SMR for every municipality and period SMR[i,j]<-100*exp(mediainter+inter[j]+het[i]+spat[i]) #Contribution of the i-th municipality in the j-th period to the deviance D.ij[j,i]<-Obs[j,i]*log(mu[j,i])-mu[j,i]-(Obs[j,i]*log(Obs[j,i])-Obs[j,i]) } #Prior distribution for the non-spatial effect het[i]~dnorm(0,prec.het) #Contribution of the i-th municipality to the deviance D.i[i]<-sum(D.ij[,i]) } #Deviance D<- -2*sum(D.i[]) #Prior distribution for the spatial effect spat[1:nmuni]~car.normal(map[],w[],nvec[],prec.spat) #Prior distribution for the mean risk for every municipality and period mediainter~dnorm(0,0.01) #Prior distribution for the global time trend inter[1:nperiods]~car.normal(mapT[],wT[],nvecT[],prec.inter) #Prior distribution for the precision parameters in the model prec.spat~dgamma(0.5,0.005) prec.inter~dgamma(0.5,0.005) prec.het~dgamma(0.5,0.005) }