-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAPR_Transience_MultiEvent_constant.jags
78 lines (54 loc) · 1.84 KB
/
MAPR_Transience_MultiEvent_constant.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
model {
# -------------------------------------------------
# Parameters:
# phi: survival probability for adults
# p: recapture probability when breeding
# -------------------------------------------------
# Priors and constraints
mean.phi ~ dunif(0, 1) # Prior for mean survival
mean.p ~ dunif(0, 1) # Prior for mean recapture
emigrate ~ dunif(0,0.25)
# 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)
ps[2,i,t,3]<-mean.phi*emigrate
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]<-mean.p
po[2,i,t,2]<-(1-mean.p)
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
}