Supplement to Stamation et al. (2020) - Endang Species Res 41:373-383 - https://doi.org/10.3354/esr01031 Supplement 2 ## JAGS script for superpopulation model for SRW ## ############################################### # Parameters ############################################### # phi Survival probability # p Detection probability # b Entry probability # psi Inclusion probability (change of being in the area) # # Priors and constraints for (i in 1:M){ alpha[i,1] <- alpha0 for (t in 1:(n.occasions-1)){ phi[i,t] <- mean.phi logit(alpha[i,t+1]) <- beta0[1] + beta0[2]*(cowgap[i,t+1]-4) } #t for (t in 1:n.occasions){ logit(p[i,t]) <- mean.lp + epsilon[i] } #t } #i mean.phi ~ dunif(0, 1) # Prior for mean survival mean.lp <- log(mean.p / (1-mean.p)) mean.p ~ dunif(0, 1) # Prior for mean capture for (i in 1:M){ epsilon[i] ~ dnorm(0, tau) } tau <- pow(sigma, -2) sigma ~ dunif(0, 5) # Prior for sd of indv. variation of p sigma2 <- pow(sigma, 2) psi ~ dunif(0, 1) # Prior for inclusion probability alpha0 ~ dunif(0, 1) # Prior for initially in zone for(j in 1:2){ beta0[j] ~ dunif(-5,5) # Prior for variables for probabil } # Dirichlet prior for entry probabilities for (t in 1:n.occasions){ beta[t] ~ dgamma(1, 1) b[t] <- beta[t] / sum(beta[1:n.occasions]) } # Convert entry probs to conditional entry probs nu[1] <- b[1] for (t in 2:n.occasions){ nu[t] <- b[t] / (1-sum(b[1:(t-1)])) } #t # Likelihood for (i in 1:M){ # First occasion # State process w[i] ~ dbern(psi) # Draw latent inclusion z[i,1] ~ dbern(nu[1]) pres[i,1] ~ dbern(alpha[i,1]) # Observation process mu1[i] <- z[i,1] * p[i,1] * w[i] * pres[i,1] y[i,1] ~ dbern(mu1[i]) # Subsequent occasions for (t in 2:n.occasions){ # State process q[i,t-1] <- 1-z[i,t-1] mu2[i,t] <- phi[i,t-1] * z[i,t-1] + nu[t] * prod(q[i,1:(t-1)]) z[i,t] ~ dbern(mu2[i,t]) pres[i,t] ~ dbern(alpha[i,t]) # Observation process mu3[i,t] <- z[i,t] * p[i,t] * w[i] * pres[i,t] y[i,t] ~ dbern(mu3[i,t]) } #t } #i # Calculate derived population parameters # List if individual i is present at time t for (i in 1:M){ for (t in 1:n.occasions){ u[i,t] <- z[i,t]*w[i] # Deflated latent state (u) } #t } #i for (i in 1:M){ recruit[i,1] <- u[i,1] cowgap[i,1] <- 0 for (t in 2:n.occasions){ recruit[i,t] <- (1-max(u[i,1:(t-1)])) * u[i,t] # Need to change so that it only gives 1 if newly recruited cowgap[i,t] <- t - max(pres[i,1:(t-1)] * 1:(t-1)) } #t } #i for (t in 1:n.occasions){ Np[t] <- sum(u[1:M,t]) # Actual population size available to capture N[t] <- sum(z[1:M, t]) # Actual population size B[t] <- sum(recruit[1:M,t]) # Number of entries } #t # for(tt in 1:(n.occasions-1)){ # lambda[tt] <- N[tt+1]/N[tt] # lambdap[tt] <- Np[tt+1]/Np[tt] # } #tt for (i in 1:M){ Nind[i] <- sum(u[i,1:n.occasions]) Nalive[i] <- 1-equals(Nind[i], 0) # Indicator if ever alive } #i Nsuper <- sum(Nalive[]) # Superpopulation size # Return rate for(j in 1:12){ Return[j] <- beta0[1] + beta0[2]*(j-4) }