-
Notifications
You must be signed in to change notification settings - Fork 1
/
AYNA_IPM_projection_longline_v1.jags
287 lines (189 loc) · 13 KB
/
AYNA_IPM_projection_longline_v1.jags
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
model {
#-------------------------------------------------
# integrated population model for the Gough AYNA population
# - age structured model with 6 age classes
# - adult survival based on CMR ringing data
# - pre breeding census, female-based assuming equal sex ratio & survival
# - productivity based on Area 1 nest monitoring data
# - simplified population process with informed prior for adults skipping breeding and uninformed immatures recruiting
# -------------------------------------------------
#-------------------------------------------------
# 1. PRIORS FOR ALL DATA SETS
#-------------------------------------------------
# -------------------------------------------------
# 1.1. Priors and constraints FOR FECUNDITY
# -------------------------------------------------
for (t in 1:T){
ann.fec[t] ~ dunif(0.2,0.8) # Priors on fecundity can range from 0-1 chicks per pair (constrained based on our data)
imm.rec[t]~dunif(0.15,0.75) ## RECRUITMENT PROBABILITY COULD SET MORE INFORMATIVE PRIOR HERE
skip.prob[t]~dunif(0.15,0.45) ## PRIOR FOR ADULT BREEDER SKIPPING PROBABILITY from Cuthbert paper that reported breeding propensity of 0.66
} #t
# -------------------------------------------------
# 1.2. Priors and constraints FOR POPULATION COUNTS
# -------------------------------------------------
for (s in 1:n.sites){ ### start loop over every study area
N.est[1,s] ~ dunif(0,200) ## draw random value from a uniform distribution between 0 and 200 for initial population size
mean.lambda[s] ~ dunif(0,10) #Prior for mean growth rate
sigma.proc[s] ~ dunif(0,10) #Prior for SD of state process (annual variation in pop size)
sigma2.proc[s]<-pow(sigma.proc[s],2)
tau.proc[s]<-pow(sigma.proc[s],-2)
sigma.obs[s] ~ dunif(0,100) #Prior for SD of observation process (variation in detectability)
sigma2.obs[s]<-pow(sigma.obs[s],2)
tau.obs[s]<-pow(sigma.obs[s],-2)
}
# -------------------------------------------------
# 1.3. Priors and constraints FOR SURVIVAL
# -------------------------------------------------
### RECAPTURE PROBABILITY
mean.p ~ dunif(0, 1) # Prior for mean recapture
logit.p <- log(mean.p / (1-mean.p)) # Logit transformation
for (t in 1:T){
logit(p[t]) <- logit.p + capt.raneff[t]
capt.raneff[t] ~ dnorm(0, tau.capt)
}
### SURVIVAL PROBABILITY
for (i in 1:nind){
for (t in f[i]:(T-1)){
logit(phi[i,t]) <- mu[AGEMAT[i,t]] + surv.raneff[t] + bycatch*longline[t]
} #t
} #i
## AGE-SPECIFIC SURVIVAL
for (age in 1:2){
beta[age] ~ dunif(0, 1) # Priors for age-specific survival
mu[age] <- log(beta[age] / (1-beta[age])) # Logit transformation
}
## RANDOM TIME EFFECT ON SURVIVAL
for (t in 1:(T-1)){
surv.raneff[t] ~ dnorm(0, tau.surv)
}
### PRIORS FOR RANDOM EFFECTS
sigma.surv ~ dunif(0, 10) # Prior for standard deviation of survival
tau.surv <- pow(sigma.surv, -2)
sigma.capt ~ dunif(0, 10) # Prior for standard deviation of capture
tau.capt <- pow(sigma.capt, -2)
### PRIOR FOR BYCATCH EFFECTS
bycatch ~ dnorm(0,3)
#-------------------------------------------------
# 2. LIKELIHOODS AND ECOLOGICAL STATE MODEL
#-------------------------------------------------
# -------------------------------------------------
# 2.1. System process: female based matrix model
# -------------------------------------------------
for (tt in 2:T){
## THE PRE-BREEDING YEARS ##
nestlings[tt] <- ann.fec[tt] * 0.5 * Ntot.breed[tt] ### number of locally produced FEMALE chicks
JUV[tt] ~ dpois(nestlings[tt]) ### need a discrete number otherwise dbin will fail, dpois must be >0
N1[tt] ~ dbin(ann.surv[1,tt-1], round(JUV[tt-1])) ### number of 1-year old survivors
N2[tt] ~ dbin(ann.surv[1,tt-1], round(N1[tt-1])) ### number of 2-year old survivors
N3[tt] ~ dbin(ann.surv[1,tt-1], round(N2[tt-1])) ### number of 3-year old survivors
N4[tt] ~ dbin(ann.surv[1,tt-1], round(N3[tt-1])) ### number of 4-year old survivors
N5[tt] ~ dbin(ann.surv[1,tt-1], round(N4[tt-1])) ### number of 5-year old survivors
## THE POTENTIAL RECRUITING YEARS ##
N6[tt] ~ dbin(ann.surv[1,tt-1], round(N5[tt-1])) ### number of 6-year old survivors that are ready for recruitment
N.notrecruited[tt] ~ dbin(ann.surv[2,tt-1], round(max(10,non.recruits[tt-1]))) ### number of not-yet-recruited birds surviving from previous year
non.recruits[tt]<-(N6[tt]+N.notrecruited[tt])-ann.recruits[tt] ## number of birds that do not recruit is the sum of all available minus the ones that do recruit
## THE BREEDING YEARS ##
Ntot.breed[tt] ~ dpois(pop.size[tt]) ### the annual number of breeding birds is the estimate from the count SSM
ann.recruits[tt] ~ dbin(imm.rec[tt],round(N6[tt]+N.notrecruited[tt])) ### Ntot.breed[tt]-Nold.breed[tt]+1)) ### this total number comprises a bunch of new recruits, which is the number of total breeders that are not old breeders
Nold.breed[tt]<- N.pot.breed[tt]-N.non.breed[tt] ### number of old breeders is survivors from previous year minus those that skip a year of breeding
N.pot.breed[tt] ~ dbin(ann.surv[2,tt-1], round(sum(Ntot.breed[tt-1],N.non.breed[tt-1]))) ### number of potential old breeders is the number of survivors from previous year breeders and nonbreeders
N.non.breed[tt] ~ dbin(skip.prob[tt], round(N.pot.breed[tt])) ### number of old nonbreeders (birds that have bred before and skip breeding)
} # tt
### INITIAL VALUES FOR COMPONENTS FOR YEAR 1 - based on stable stage distribution from previous model
JUV[1]<-round(Ntot.breed[1]*0.5*ann.fec[1])
N1[1]<-round(Ntot.breed[1]*0.17574058)
N2[1]<-round(Ntot.breed[1]*0.11926872)
N3[1]<-round(Ntot.breed[1]*0.10201077)
N4[1]<-round(Ntot.breed[1]*0.08725001)
N5[1]<-round(Ntot.breed[1]*0.07462511)
non.recruits[1]<-round(Ntot.breed[1]*0.3147774)
Ntot.breed[1]<-sum(y.count[1,])
N.non.breed[1]<- round(Ntot.breed[1]*0.12632740)
# -------------------------------------------------
# 2.2. Observation process for population counts: state-space model of annual counts
# -------------------------------------------------
for (s in 1:n.sites){ ### start loop over every study area
## State process for entire time series
for (t in 1:(T-1)){
lambda[t,s] ~ dnorm(mean.lambda[s], tau.proc[s]) # Distribution for random error of growth rate
N.est[t+1,s]<-N.est[t,s]*lambda[t,s] # Linear predictor (population size based on past pop size and change rate)
} # run this loop over nyears
## Observation process
for (t in 1:T){
y.count[t,s] ~ dnorm(N.est[t,s], tau.obs[s]) # Distribution for random error in observed numbers (counts)
} # run this loop over t= nyears
} ## end site loop
# -------------------------------------------------
# 2.3. Likelihood for fecundity: Poisson regression from the number of surveyed broods
# -------------------------------------------------
for (t in 1:(T-1)){
J[t] ~ dpois(rho.fec[t])
rho.fec[t] <- R[t]*ann.fec[t]
} # close loop over every year in which we have fecundity data
# -------------------------------------------------
# 2.4. Likelihood for adult and juvenile survival from CMR
# -------------------------------------------------
# Likelihood
for (i in 1:nind){
# Define latent state at first capture
z[i,f[i]] <- 1
for (t in (f[i]+1):T){
# State process
z[i,t] ~ dbern(mu1[i,t])
mu1[i,t] <- phi[i,t-1] * z[i,t-1]
# Observation process
y[i,t] ~ dbern(mu2[i,t])
mu2[i,t] <- p[t] * z[i,t]
} #t
} #i
#-------------------------------------------------
# 3. DERIVED PARAMETERS FOR OUTPUT REPORTING
#-------------------------------------------------
## DERIVED SURVIVAL PROBABILITIES PER YEAR
for (t in 1:(T-1)){
for (age in 1:2){
logit(ann.surv[age,t]) <- mu[age] + surv.raneff[t]
}
}
## DERIVED POPULATION SIZE PER YEAR
for (t in 1:T){
pop.size[t]<-max(10,sum(N.est[t,1:n.sites])) ## introduced max to prevent this number from being 0 which leads to invalid parent error on Ntot.breed
}
## DERIVED OVERALL POPULATION GROWTH RATE
pop.growth.rate <- mean(lambda[1:(T-1),1:n.sites]) # Arithmetic mean for whole time series
#-------------------------------------------------
# 4. PROJECTION INTO FUTURE
#-------------------------------------------------
for (tt in (T+1):FUT.YEAR){
## RANDOMLY DRAW DEMOGRAPHIC RATES FROM PREVIOUS YEARS WHILE AVOIDING THAT INDEX BECOMES 0
FUT[tt] ~ dunif(1.5,(T-0.5))
FUT.int[tt]<-round(FUT[tt])
# -------------------------------------------------
# 4.1. System process for future
# -------------------------------------------------
## THE PRE-BREEDING YEARS ##
nestlings[tt] <- round(ann.fec[FUT.int[tt]] * 0.5 * Ntot.breed[tt]) ### number of locally produced FEMALE chicks
N1[tt] ~ dbin(ann.surv[1,FUT.int[tt]-1], round(nestlings[tt-1])) ### number of 1-year old survivors
N2[tt] ~ dbin(ann.surv[1,FUT.int[tt]-1], round(N1[tt-1])) ### number of 2-year old survivors
N3[tt] ~ dbin(ann.surv[1,FUT.int[tt]-1], round(N2[tt-1])) ### number of 3-year old survivors
N4[tt] ~ dbin(ann.surv[1,FUT.int[tt]-1], round(N3[tt-1])) ### number of 4-year old survivors
N5[tt] ~ dbin(ann.surv[1,FUT.int[tt]-1], round(N4[tt-1])) ### number of 5-year old survivors
## THE POTENTIAL RECRUITING YEARS ##
N6[tt] ~ dbin(ann.surv[1,FUT.int[tt]-1], round(N5[tt-1])) ### number of 6-year old survivors that are ready for recruitment
N.notrecruited[tt] ~ dbin(ann.surv[2,FUT.int[tt]-1], round(max(10,non.recruits[tt-1]))) ### number of not-yet-recruited birds surviving from previous year
non.recruits[tt]<-(N6[tt]+N.notrecruited[tt])-ann.recruits[tt] ### number of birds that do not recruit is the sum of all available minus the ones that do recruit
ann.recruits[tt] ~ dbin(imm.rec[FUT.int[tt]],round(N6[tt]+N.notrecruited[tt])) ### new recruits
## THE BREEDING YEARS ##
Ntot.breed[tt] <- Nold.breed[tt] + ann.recruits[tt] ### the annual number of breeding birds is the estimate from the count SSM
Nold.breed[tt]<- N.pot.breed[tt]-N.non.breed[tt] ### number of old breeders is survivors from previous year minus those that skip a year of breeding
N.pot.breed[tt] ~ dbin(ann.surv[2,FUT.int[tt]-1], round(sum(Ntot.breed[tt-1],N.non.breed[tt-1]))) ### number of potential old breeders is the number of survivors from previous year breeders and nonbreeders
N.non.breed[tt] ~ dbin(skip.prob[FUT.int[tt]], round(N.pot.breed[tt])) ### number of old nonbreeders (birds that have bred before and skip breeding)
## CALCULATE ANNUAL POP GROWTH RATE ##
fut.lambda[tt-19] <- Ntot.breed[tt]/Ntot.breed[tt-1]
} # tt
# -------------------------------------------------
# 4.2. DERIVED POPULATION GROWTH RATE FOR FUTURE
# -------------------------------------------------
## DERIVED OVERALL POPULATION GROWTH RATE
future.growth.rate <- mean(fut.lambda[1:10]) # projected ANNUAL growth rate in the future
}