model{

for(i in 1:N){
	Nfrat[i] ~ dpois(lambda[i])
	log(lambda[i]) <- log(Npop[i]) + beta0 + beta.ses[Ses3b[i]] + beta.dur*true.dur[i] + psi[IndexConc[i]] + nu[IndexConc[i]]
	true.dur[i] ~ dnorm(mu.true,tau.true)
	dur[i] ~ dnorm(true.dur[i],tau.err)
}

nu[1:278] ~ car.normal(adj[],weights[],num[],tau.nu) #CAR prior for spatially structured effects

for(j in 1:278){
	psi[j] ~ dnorm(0,tau.psi)
}

tau.psi ~ dgamma(0.5,0.005)
tau.nu ~ dgamma(0.5, 0.005) # diffuse gamma hyperprior for tau.nu
beta0 ~ dnorm(0,0.001)
beta.ses[1] <- 0
beta.ses[2] ~ dnorm(0,0.001)
beta.ses[3] ~ dnorm(0,0.001)
beta.dur ~ dnorm(0,0.001)
mu.true ~ dnorm(0,0.001)
tau.true ~ dgamma(0.5,0.005)
sigmasq.true <- 1/tau.true
rho <- 0.71
sigmasq.err <- sigmasq.true*(1-rho)/rho
tau.err <- 1/sigmasq.err
}
