#JAGS model for Bayesian analysis # Pedro 05/25/2015 model { ## Priors fixed Betas1 ~ dnorm(0,0.0001) Betas2 ~ dnorm(0,0.0001) for (j in 1:Nstems) { Betas3[j] ~ dnorm(0,0.0001) } for (k in 1:Ntsf) { Betas4[k] ~ dnorm(0,0.0001) } for (j in 1:Ntsf) { for (k in 1:Nstems) { Betas5[j,k] ~ dnorm(0,0.0001) } } ## Priors random intercepts for (j in 1:Nyear) { alpha.y[j] ~ dnorm(0,tau.year.a) beta.y[j] ~ dnorm(0,tau.year.b) } for (i in 1:Nyear) { for (k in 1:Npop) { alpha.p[k,i] ~ dnorm(0,tau.plot.a) beta.p[k,i] ~ dnorm(0,tau.plot.b) } } ## priors for random tau.plot.a <- 1/(sigma.plot.a*sigma.plot.a) tau.plot.b <- 1/(sigma.plot.b*sigma.plot.b) tau.year.a <- 1/(sigma.plot.a*sigma.year.a) tau.year.b <- 1/(sigma.plot.b*sigma.year.b) tau.eps <- 1/(sigma.eps*sigma.eps) sigma.eps ~ dunif(0.001,10) sigma.plot.a ~ dunif(0.001,10) sigma.plot.b ~ dunif(0.001,10) sigma.year.a ~ dunif(0.001,10) sigma.year.b ~ dunif(0.001,10) ## Likelihood for(i in 1:N){ Y[i] ~ dbern( mu[i] ) mu[i] <- eta[i] eta[i] <- 1/(1+exp(-(Betas1 + (Betas2 + beta.p[pp[i],yy[i]] + beta.y[yy[i]])*X[i] + alpha.p[pp[i],yy[i]] +alpha.y[yy[i]] + Betas3[stem[i]] + Betas4[tsf[i]] + Betas5[tsf[i],stem[i]]))) } }