forked from zipkinlab/Saunders_etal_2019_Ecol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLincoln.bug
94 lines (82 loc) · 5.33 KB
/
Lincoln.bug
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
model {
# priors for initial population sizes (mean first 5 years Lincoln, SD 100,000)
af.N[1,1] ~ dnorm(720000,1E-10) #assuming these come from previous Lincoln analysis; adult female central (1)
af.N[2,1] ~ dnorm(600000,1E-10) #adult female eastern (2)
am.N[1,1] ~ dnorm(615000,1E-10) #adult male central
am.N[2,1] ~ dnorm(530000,1E-10) #adult male eastern
# Priors and constraints for population means and variances
for (i in 1:2){ # 1 Central, 2 Eastern pop
f.af.x[i] ~ dunif(0.005,0.2) # uniform prior for mean Brownie recovery
f.af.mu[i] <- logit(f.af.x[i]) #adult female mean recovery rate?
f.am.x[i] ~ dunif(0.005,0.2)
f.am.mu[i] <- logit(f.af.x[i]) #adult male mean recov rate
f.juv.x[i] ~ dunif(0.005,0.2)
f.juv.mu[i] <- logit(f.af.x[i]) #juvenile mean recov rate
s.loc.x[i] ~ dunif (0,1) # prior for S from local to HY stage
s.loc.mu[i] <- logit(s.loc.x[i]) #prior for S from local to HY stage, mean
# priors for annual SD of annual recovery rate (logit scale)
f.af.sd[i] ~ dunif(0.05,2)
f.am.sd[i] ~ dunif(0.05,2)
f.juv.sd[i] ~ dunif(0.05,2)
s.loc.sd[i] ~ dunif (0.05,2)
f.af.tau[i] <- pow(f.af.sd[i],-2)
f.am.tau[i] <- pow(f.am.sd[i],-2)
f.juv.tau[i] <- pow(f.juv.sd[i],-2)
s.loc.tau[i] <- pow(s.loc.sd[i],-2)
# priors for annual growth rates and fecundities
F.x[i] ~ dunif(0,4) # logical bounds on fecundity (F) with 4 egg clutch
afr.x[i] ~ dunif(-1,1) # uniform prior for mean growth rate, ad females
amr.x[i] ~ dunif(-1,1) # ad males
F.sd[i] ~ dunif(0.01,1)
afr.sd[i] ~ dunif(0.01,1) # uniform prior for ann variation in mean growth rate
amr.sd[i] ~ dunif(0.01,1)
F.tau[i] <- pow(F.sd[i],-2)
afr.tau[i] <- pow(afr.sd[i],-2)
amr.tau[i] <- pow(amr.sd[i],-2)
# Generate annual parameter estimates
for (y in 1:yrs){ #yrs is 49 here
# generate recovery rates
logit.f.af[i,y] ~ dnorm(f.af.mu[i],f.af.tau[i]) #uses mean and variance from above, adult female
logit.f.am[i,y] ~ dnorm(f.am.mu[i],f.am.tau[i]) #uses mean and variance from above, adult male
logit.f.juv[i,y] ~ dnorm(f.juv.mu[i],f.juv.tau[i]) #uses mean and variance from above, juvenile
logit.s.loc[i,y] ~ dnorm(s.loc.mu[i],s.loc.tau[i]) #uses mean and variance from above, S from local to HY stage
logit(f.af[i,y]) <- logit.f.af[i,y]
logit(f.am[i,y]) <- logit.f.am[i,y]
logit(f.juv[i,y]) <- logit.f.juv[i,y]
logit(s.loc[i,y]) <- logit.s.loc[i,y]
f.loc[i,y] <- s.loc[i,y]*f.juv[i,y] #true recovery rates for locals a product of survival and recovery?
# generate process components
af.r[i,y] ~ dnorm(afr.x[i],afr.tau[i]) # need F (fecundity, not recov!) for each year, but last lambda not used, af.r is mean growth rate from above
am.r[i,y] ~ dnorm(amr.x[i],amr.tau[i]) #am.r is mean growth rate for adult males pop segment
F[i,y] ~ dnorm(F.x[i],F.tau[i]) # Fecundity cannot be <0 or >4
af.lambda[i,y] <- exp(af.r[i,y]) # convert r to lambda by exponentiating, r = log(lambda), converting from stochastic population growth rate to finite growth rate
am.lambda[i,y] <- exp(am.r[i,y])
} # close y
# State process (estimate Fecundity in year 1)
juv.N[i,1] <- trunc(af.N[i,1]*F[i,1]) #trunc truncates towards 0. juv pop size function of adult females and fecundity
for (y in 2:yrs){
af.N[i,y] <- trunc(af.N[i,y-1] * af.lambda[i,y-1]) #adult female pop size function of previous yr times lambda
am.N[i,y] <- trunc(am.N[i,y-1] * am.lambda[i,y-1]) #adult male pop size function of previous yr times lambda
juv.N[i,y] <- trunc(af.N[i,y] * F[i,y])
} # close y
} # close i
# observation process, recoveries and harvest data
for (y in 1:yrs){
C.af.R[y] ~ dbin(f.af[1,y],C.af.B[y]) #central adult female recovery data, bin distribution function of adult female recoveries and central region females banded
C.am.R[y] ~ dbin(f.am[1,y],C.am.B[y]) #central adult male recovery data, function of adult male recoveries and central males banded
C.juv.R[y] ~ dbin(f.juv[1,y],C.juv.B[y]) #central juvenile recovery data, function of juv recoveries and central imms banded
C.loc.R[y] ~ dbin(f.loc[1,y],C.loc.B[y]) #central local recovery data, function of local recoveries and central locals banded
E.af.R[y] ~ dbin(f.af[2,y],E.af.B[y]) #ditto for eastern
E.am.R[y] ~ dbin(f.am[2,y],E.am.B[y]) #ditto for eastern
E.juv.R[y] ~ dbin(f.juv[2,y],E.juv.B[y]) #ditto for eastern
E.loc.R[y] ~ dbin(f.loc[2,y],E.loc.B[y]) #ditto for eastern
}
for (y in 2:yrs){
C.af.H[y] ~ dbin(f.af[1,y], af.N[1,y]) #ad female harvest data dist. binom as adult female pop size (af.N) and recovery rate (f.af)
C.am.H[y] ~ dbin(f.am[1,y], am.N[1,y]) #ad male harvest data dist. binom as adult male pop size (am.N) and recovery rate (f.am)
C.juv.H[y] ~ dbin(f.juv[1,y], juv.N[1,y]) #juv harvest data (imm in excel sheet) dist. as juv pop size and recovery rate
E.af.H[y] ~ dbin(f.af[2,y], af.N[2,y]) #ditto for eastern
E.am.H[y] ~ dbin(f.am[2,y], am.N[2,y]) #ditto for eastern
E.juv.H[y] ~ dbin(f.juv[2,y], juv.N[2,y]) #ditto for eastern
}
} # end bugs model