-
Notifications
You must be signed in to change notification settings - Fork 1
/
AYNA_IPM_v4.jags
299 lines (198 loc) · 14.2 KB
/
AYNA_IPM_v4.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
288
289
290
291
292
293
294
295
296
297
298
299
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
# - FOUR future scenarios to project population growth after eradication, bycatch mitigation or no management
# -------------------------------------------------
#-------------------------------------------------
# 1. PRIORS FOR ALL DATA SETS
#-------------------------------------------------
# -------------------------------------------------
# 1.1. Priors and constraints FOR FECUNDITY
# -------------------------------------------------
for (t in 1:T){
ann.fec[t] ~ dunif(0.01,0.99) ## Informative Priors on fecundity based on Cuthbert et al 2003: dnorm(0.67,50) T(0.01,0.99)
imm.rec[t] ~ dunif(0.01,0.99) ## Informative Priors on annual recruitment based on Cuthbert et al 2003: dnorm(0.28,10) T(0.01,0.99)
skip.prob[t] ~ dunif(0.01,0.99) ## PRIOR FOR ADULT BREEDER SKIPPING PROBABILITY from Cuthbert paper that reported breeding propensity of 0.66: dnorm(0.34,10) T(0.01,0.99)
} #t
# -------------------------------------------------
# 1.2. Priors and constraints FOR POPULATION COUNTS
# -------------------------------------------------
for (s in 1:n.sites){ ### start loop over every study area
## prop.site[s] ~ dnorm(prop[s],100) T(0,1) ### the proportion of the total population that is in 1 of the 11 census areas
for (t in 1:T){ ### start loop over every year
sigma.obs[t,s] ~ dunif(1,1000) #Prior for SD of observation process (variation in detectability)
tau.obs[t,s]<-pow(sigma.obs[t,s],-2)
} ## close year loop
} ## close site loop
# -------------------------------------------------
# 1.3. Priors and constraints FOR SURVIVAL
# -------------------------------------------------
### RECAPTURE PROBABILITY
mean.p ~ dunif(0.01, 0.99) # 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[AGEMAT[i,t],t] ##+ bycatch*longline[t]
} #t
} #i
## AGE-SPECIFIC SURVIVAL
for (age in 1:2){
beta[age] ~ dunif(0.5, 0.99) # Priors for age-specific survival
mu[age] <- log(beta[age] / (1-beta[age])) # Logit transformation
## RANDOM TIME EFFECT ON SURVIVAL VARIES BY AGE GROUP
for (t in 1:(T-1)){
surv.raneff[age,t] ~ dnorm(0, tau.surv[age])
}
### PRIORS FOR RANDOM EFFECTS
sigma.surv[age] ~ dunif(1, 10) # Prior for standard deviation of survival
tau.surv[age] <- pow(sigma.surv[age], -2)
}
sigma.capt ~ dunif(1, 10) # Prior for standard deviation of capture
tau.capt <- pow(sigma.capt, -2)
### PRIOR FOR BYCATCH EFFECTS
#bycatch ~ dnorm(0,tau.byc)
sigma.byc ~ dunif(1, 10) # Prior for standard deviation of capture
tau.byc <- pow(sigma.byc, -2)
#-------------------------------------------------
# 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] <- round(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], max(5,round(JUV[tt-1]))) ### number of 1-year old survivors
N2[tt] ~ dbin(ann.surv[1,tt-1], max(5,round(N1[tt-1]))) ### number of 2-year old survivors
N3[tt] ~ dbin(ann.surv[1,tt-1], max(5,round(N2[tt-1]))) ### number of 3-year old survivors
N4[tt] ~ dbin(ann.surv[1,tt-1], max(5,round(N3[tt-1]))) ### number of 4-year old survivors
N5[tt] ~ dbin(ann.surv[1,tt-1], max(5,round(N4[tt-1]))) ### number of 5-year old survivors
## THE POTENTIAL RECRUITING YEARS ##
N6[tt] ~ dbin(ann.surv[2,tt-1], max(5,round(N5[tt-1]))) ### number of 6-year old survivors that are ready for recruitment - using adult survival
ann.recruits[tt] ~ dbin(imm.rec[tt],max(5,round(N6[tt]+N.notrecruited[tt]))) ### annual recruits are those age 6 or older that haven't recruited yet
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
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
## THE BREEDING YEARS ##
Ntot.breed[tt] <- Nold.breed[tt] + ann.recruits[tt] ### the annual number of breeding birds is the sum of old breeders and recent recruits
Nold.breed[tt] <- round(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 that return from sabbatical
#N.non.breed[tt] ~ dbin((skip.prob[tt]), max(1,round(N.pot.breed[tt]))) ### number of old nonbreeders (birds that have bred before and skip breeding)
N.non.breed[tt] ~ dbin(skip.prob[tt],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] ~ dunif(600,750) # 675 ## sum of pairs observed in year 1 is 675
N.non.breed[1]<- round(Ntot.breed[1]*0.12632740)
# -------------------------------------------------
# 2.2. Observation process for population counts: state-space model of annual counts
# -------------------------------------------------
## State process for entire time series
for (t in 1:T){
#Nobs[t]<-max(1,round(Ntot.breed[t]))
#N.est[t,1:n.sites] ~ dmulti(prop.site, Nobs[t]) # pop in a given study area should be proportion of total breeding population
## Observation process
for (s in 1:n.sites){ ### start loop over every study area
N.est[t,s] <- round(prop[s] * Ntot.breed[t]) # pop in a given study area should be proportion of total breeding population
y.count[t,s] ~ dnorm(max(1,N.est[t,s]), tau.obs[t,s]) # Distribution for random error in observed numbers (counts)
} ## end site loop
} ## end year loop
# -------------------------------------------------
# 2.3. Likelihood for fecundity: Poisson regression from the number of surveyed broods
# -------------------------------------------------
for (t in 1:(T)){ ### T-1 or not
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] * (1-skip.prob[t]) ### added skip.prob[t] because skippers cannot be observed
} #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[age,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 POPULATION GROWTH RATE PER YEAR
for (t in 1:(T-1)){
lambda[t]<-Ntot.breed[t+1]/max(1,Ntot.breed[t]) ## division by 0 creates invalid parent value
} ## end year loop
## DERIVED OVERALL POPULATION GROWTH RATE
#pop.growth.rate <- mean(lambda[1:(T-1)]) # Arithmetic mean for whole time series
## DERIVED MEAN FECUNDITY
mean.fec <- mean(ann.fec)
mean.rec <- mean(imm.rec)
mean.skip <- mean(skip.prob)
#-------------------------------------------------
# 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,15.5) ### CHANGE FROM 1.5 to 15.5 to only sample from last three years when survival was high
#FUT.int[tt]<-round(FUT[tt])
#fut.fec[tt] ~ dnorm(mean.fec,tau.fec) ### CHANGE FROM mean.fec to 0.69 + 0.16 from Caravaggi et al. 2018 for eradication scenario
# -------------------------------------------------
# 4.1. System process for future
# -------------------------------------------------
## THE PRE-BREEDING YEARS ##
nestlings[tt] <- round(mean.fec* 0.5 * Ntot.breed[tt]) ### number of locally produced FEMALE chicks based on average fecundity - to use just one take ann.fec[FUT.int[tt]]
N1[tt] ~ dbin(beta[1], max(1,round(nestlings[tt-1]))) ### number of 1-year old survivors
N2[tt] ~ dbin(beta[1], round(N1[tt-1])) ### number of 2-year old survivors
N3[tt] ~ dbin(beta[1], round(N2[tt-1])) ### number of 3-year old survivors
N4[tt] ~ dbin(beta[1], round(N3[tt-1])) ### number of 4-year old survivors
N5[tt] ~ dbin(beta[1], round(N4[tt-1])) ### number of 5-year old survivors
## THE POTENTIAL RECRUITING YEARS ##
N6[tt] ~ dbin(beta[2], round(N5[tt-1])) ### number of 6-year old survivors that are ready for recruitment - using adult survival
N.notrecruited[tt] ~ dbin(beta[2], 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(mean.rec,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(beta[2], 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(mean.skip, 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]/max(1,Ntot.breed[tt-1]) ### inserted safety to prevent denominator being 0
} # 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 - somehow no longer works from v3 onwards
} ## END MODEL LOOP