-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMAPR_IPM_REV1_juvsurv.jags
210 lines (151 loc) · 9.42 KB
/
MAPR_IPM_REV1_juvsurv.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
model {
#-------------------------------------------------
# - population model for the MacGillivray's Prion population
# - age structured model with 4 age classes
# - adult survival based on CMR ringing data with m-array and temporal variation
# - productivity based on Prion Cave nest monitoring data
# - TWO future scenarios to project population growth with and without eradication
# -------------------------------------------------
#-------------------------------------------------
# 1. PRIORS FOR ALL DATA SETS
#-------------------------------------------------
# -------------------------------------------------
# 1.1. Priors and constraints FOR FECUNDITY
# -------------------------------------------------
mean.fec[1] ~ dunif(0,1) ## uninformative prior for BAD YEARS
mean.fec[2] ~ dunif(0,1) ## uninformative prior for GOOD YEARS
prop.good ~ dunif(0,1) ## proportion of years that is good or bad (to allow past variation when good years were more common)
orig.fec ~ dunif(0.88,0.94) ## uninformative prior for ORIGINAL FECUNDITY in proportion of years with good (similar to 2016) fecundity
full.fec ~ dnorm(0.519,100) T(0.1,1) ## prior for full fecundity without predation from Nevoux & Barbraud (2005) - very high precision
fec.decrease <- (prop.good-orig.fec)/(58-0) ## 58 years elapsed between original pop size data in 1957 and start of productivity time series in 2014
# -------------------------------------------------
# 1.2. Priors and constraints FOR SURVIVAL
# -------------------------------------------------
# -------------------------------------------------
# Parameters:
# phi: survival probability for adults
# p: recapture probability when breeding
# emigrate: probability to emigrate into inaccessible part of Prion Cave
# -------------------------------------------------
# Priors and constraints
for (t in 1:(n.occasions-1)){
#logit(phi[t]) <- mu.phi + surv.raneff[t]
#surv.raneff[t] ~ dnorm(0, tau.phi)
p[t] ~ dunif(0, 1)
emigrate[t] ~ dunif(0,0.25)
}
mean.phi ~ dunif(0, 1) # Prior for mean survival
#juv.surv.prop ~ dnorm(mean.juv.surv.prop,1000) T(0,1)
mean.juv.surv ~ dunif(0.02,0.35) ## based on juvenile survival for Balearic shearwaters in the Med.
#mean.juv.surv ~ dunif(0.70,0.85) ## based on juvenile survival for Balearic shearwaters in the Med, and Grey-faced Petrels
#-------------------------------------------------
# 2. LIKELIHOODS AND ECOLOGICAL STATE MODEL
#-------------------------------------------------
# -------------------------------------------------
# 2.1. System process: female based matrix model
# -------------------------------------------------
for (scen in 1:2){
### INITIAL VALUES FOR COMPONENTS FOR YEAR 1 - based on stable stage distribution from previous model
fec.proj[scen,1]<-mean.fec[year.prop.good[scen,1]+1] ## takes good or bad year fecundity
year.prop.good[scen,1] ~ dbern(orig.fec)
### INITIAL VALUES FOR COMPONENTS FOR YEAR 1 - based on stable stage distribution from previous model
JUV[1,scen]<-round(Ntot.breed[1,scen]*0.5*(mean.fec[year.prop.good[scen,1]+1]))
N1[1,scen]<-round(Ntot.breed[1,scen]*0.5*(mean.fec[year.prop.good[scen,1]+1])*mean.juv.surv)
N2[1,scen]<-round(Ntot.breed[1,scen]*0.5*(mean.fec[year.prop.good[scen,1]+1])*mean.juv.surv*mean.phi)
N3[1,scen]<-round(Ntot.breed[1,scen]*0.5*(mean.fec[year.prop.good[scen,1]+1])*mean.juv.surv*mean.phi*mean.phi)
Ntot.breed[1,scen] ~ dunif(2000000,5000000) # initial value of population size
for (tt in 2:65){
## LINEARLY DECREASING PROBABILITY OF A GOOD YEAR FROM 1956 to 2014
year.fec.prop[scen,tt]<- max(0,min(1,(orig.fec + fec.decrease*tt))) ## calculate yearly proportion of good breeding year, but constrain to 0-1 to avoid invalid parent value
year.prop.good[scen,tt] ~ dbern(year.fec.prop[scen,tt])
fec.proj[scen,tt]<-mean.fec[year.prop.good[scen,tt]+1] ## takes good or bad year fecundity
breed.prop[scen,tt] ~ dunif(0.85,0.95) ## breeding propensity
## THE PRE-BREEDERS ##
JUV[tt,scen] ~ dbin(fec.proj[scen,tt],round(0.5 * Ntot.breed[tt,scen]*breed.prop[scen,tt])) ### number of locally produced FEMALE chicks
N1[tt,scen] ~ dbin(mean.juv.surv, max(2,round(JUV[tt-1,scen]))) ### number of 1-year old survivors
N2[tt,scen] ~ dbin(mean.phi, max(2,round(N1[tt-1,scen]))) ### number of 2-year old survivors
N3[tt,scen] ~ dbin(mean.phi, max(2,round(N2[tt-1,scen]))) ### number of 3-year old survivors
## THE BREEDERS ##
Ntot.breed[tt,scen] ~ dbin(mean.phi, max(2,round(N3[tt-1,scen]+Ntot.breed[tt-1,scen]))) ### the annual number of breeding birds is the sum of old breeders and recent recruits
} # tt
for (tt in 66:PROJ){
## SELECT GOOD OR BAD OR RODENT FREE FECUNDITY FOR FUTURE
year.fec.prop[scen,tt]<- min(1,max(0,(orig.fec + fec.decrease*tt))) ## calculate yearly proportion of good breeding year, but constrain to 0-1 to avoid invalid parent value
year.prop.good[scen,tt] ~ dbern(year.fec.prop[scen,tt])
fec.proj[scen,tt]<-max(mean.fec[year.prop.good[scen,tt]+1],(scen-1)*full.fec) ## takes current fecundity for scenario 1 and full fecundity for scenario 2
breed.prop[scen,tt] ~ dunif(0.85,0.95) ## breeding propensity
## THE PRE-BREEDERS ##
JUV[tt,scen] ~ dbin(fec.proj[scen,tt],round(0.5 * Ntot.breed[tt,scen]*breed.prop[scen,tt])) ### need a discrete number otherwise dbin will fail, dpois must be >0
N1[tt,scen] ~ dbin(mean.juv.surv, max(2,round(JUV[tt-1,scen]))) ### number of 1-year old survivors
N2[tt,scen] ~ dbin(mean.phi, max(2,round(N1[tt-1,scen]))) ### number of 2-year old survivors
N3[tt,scen] ~ dbin(mean.phi, max(2,round(N2[tt-1,scen]))) ### number of 3-year old survivors
## THE BREEDERS ##
Ntot.breed[tt,scen] ~ dbin(mean.phi, max(2,round(N3[tt-1,scen]+Ntot.breed[tt-1,scen]))) ### the annual number of breeding birds is the sum of old breeders and recent recruits
} # tt
} # scen
# -------------------------------------------------
# 2.2. Likelihood for fecundity: Poisson regression from the number of surveyed broods
# -------------------------------------------------
for (t in 1:(T.fec)){ ### T-1 or not
J[t] ~ dpois(rho.fec[t])
rho.fec[t] <- R[t]*mean.fec[goodyear[t]+1]
goodyear[t] ~ dbern(prop.good)
} # close loop over every year in which we have fecundity data
# -------------------------------------------------
# 2.3. Likelihood for adult survival from multi-event model
# -------------------------------------------------
# States (S):
# 1 dead
# 2 alive in Prion Cave
# 3 alive as transient
# Observations (O):
# 1 observed
# 2 not observed
# -------------------------------------------------
# -------------------------------------------------
# Define state-transition and observation matrices
# -------------------------------------------------
for (i in 1:nind){
for (t in f[i]:(n.occasions-1)){
# Define probabilities of state S(t+1) [last dim] given S(t) [first dim]
ps[1,i,t,1]<-1 ## dead birds stay dead
ps[1,i,t,2]<-0
ps[1,i,t,3]<-0
ps[2,i,t,1]<-(1-mean.phi)
ps[2,i,t,2]<-mean.phi*(1-emigrate[t])
ps[2,i,t,3]<-mean.phi*emigrate[t]
ps[3,i,t,1]<-(1-mean.phi)
ps[3,i,t,2]<-0
ps[3,i,t,3]<-mean.phi
# Define probabilities of O(t) [last dim] given S(t) [first dim]
po[1,i,t,1]<-0
po[1,i,t,2]<-1
po[2,i,t,1]<-p[t]
po[2,i,t,2]<-(1-p[t])
po[3,i,t,1]<-0
po[3,i,t,2]<-1
} #t
} #i
# Likelihood
for (i in 1:nind){
# Define latent state at first capture
z[i,f[i]] <- 2 ## alive when first marked
for (t in (f[i]+1):n.occasions){
# State process: draw S(t) given S(t-1)
z[i,t] ~ dcat(ps[z[i,t-1], i, t-1,])
# Observation process: draw O(t) given S(t)
y[i,t] ~ dcat(po[z[i,t], i, t-1,])
} #t
} #i
# -------------------------------------------------
# 4. DERIVED PARAMETERS
# -------------------------------------------------
## DERIVED POPULATION GROWTH RATE
for (scen in 1:2){
for (tt in 1:33){
lambda[tt,scen]<-Ntot.breed[tt+67,scen]/max(1,Ntot.breed[tt+66,scen])
loglam[tt,scen]<-log(lambda[tt,scen])
} ## end of tt
growth.rate[scen] <- exp((1/(33))*sum(loglam[1:(33),scen])) ### geometric mean growth rate
} ## end of scen
} ## END MODEL LOOP