-
Notifications
You must be signed in to change notification settings - Fork 1
/
AYNA_CJS_simple.jags
75 lines (54 loc) · 1.99 KB
/
AYNA_CJS_simple.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
model {
# -------------------------------------------------
# Parameters:
# phi: survival probability, grouped by age category
# p: recapture probability when breeding
# -------------------------------------------------
## Priors and constraints
### 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:n.occasions){
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]:(n.occasions-1)){
logit(phi[i,t]) <- mu[AGEMAT[i,t]] + surv.raneff[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:(n.occasions-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)
# Likelihood
for (i in 1:nind){
# Define latent state at first capture
z[i,f[i]] <- 1
for (t in (f[i]+1):n.occasions){
# 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
# DERIVED SURVIVAL PROBABILITIES PER YEAR
for (t in 1:(n.occasions-1)){
for (age in 1:2){
logit(ann.surv[age,t]) <- mu[age] + surv.raneff[t]
}
}
}