model{ for(j in 2:t){ wr[j] ~ dbern(pier[j]) # uses the ones trick to include capture component pier[j] <- pow(p[j],m[j])*pow((1-p[j]),M[j]-m[j]) } M[1] <- 0 Mplus[1] <- R[1] for(j in 1:t-1){ # model for the number of individuals surviving from j to j+1 (D[j]=candie[j]-surv[j]) surv[j] ~ dbin(S[j],candie[j]) # candie are the marked individuals that are available to die between sample j and j+1 candie[j] <- Mplus[j] - T[j] M[j+1] <- surv[j] + T[j] # Mplus[j] is the number of individuals available after sample j Mplus[j+1] <- M[j+1] - m[j+1] + R[j+1] wd[j] ~ dbern(pied[j]) # uses the ones trick to include the marked individuals that are known to survive pied[j] <- pow(S[j],T[j]) } for(j in 1:t){ # includes the JS component littleu[j] ~ dbin(p[j],capu[j]) capn[j] <- capu[j] + M[j] } capu[1] <- round(capucont[1]) # prior for capu capucont[1] ~ dunif(0,5000) # So long as the initial value for capucont[1] > littleu[1] this value will be appropriately censored for(j in 2:t){ # capu consists of marked individuals that survive and individuals that are born. capu[j] <- capuprime[j-1] + capb[j-1] } for(j in 1:t-1){ # models the unmarked individuals that survive capuprime[j] ~ dbin(S[j],bigu[j]) # bigu[j] is the number of unmarked individuals immediately after sample j bigu[j] <- capn[j]-Mplus[j] } for(j in 1:t-1){ # models the birth into the population capbcont[j] ~ dpois(bmu[j]) capb[j] <- round(capbcont[j]) # eta is the per-capita birth rate bmu[j] <- eta[j]*capn[j] log(eta[j]) <- leta[j] leta[j] ~ dnorm(mueta[j],tau[2]) # density dependence relationship mueta[j] <- beta[3] + beta[4]*(log(capn[j])-5.5) } for(j in 1:t-1){ # density dependence relationship logit(S[j]) <- beta[1] + beta[2]*(log(capn[j])-5.5) + epss[j] epss[j] ~ dnorm(0,tau[1]) } for(j in 1:t){ logit(p[j]) <- lp[j] # random effect on capture probability lp[j] ~ dnorm(beta[5],tau[3]) } for(j in 1:3){ # prior distributions tau[j] ~ dgamma(0.001,0.001) sd[j] <- 1/sqrt(tau[j]) } # prior distributions beta[1] ~ dnorm(0,0.00001) beta[3] ~ dnorm(0,0.00001) beta[5] ~ dnorm(0,0.00001) beta[2] ~ dunif(-10,0) beta[4] ~ dunif(-10,0) }