forked from farrmt/HMSDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHMSDS_model.txt
110 lines (68 loc) · 2.39 KB
/
HMSDS_model.txt
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
model{
##Priors
for(j in 1:nsites){
#Abundance prior
alpha[j] ~ dnorm(0, 0.01)
#Detection prior
sigma[j] ~ dunif(0, 500)
}#End j loop
#OVerdispersion prior
r.N ~ dunif(0,100)
r.G ~ dunif(0,100)
#Group size prior
beta ~ dunif(0, 50)
##Likelihood
#Multinomial detection component
for(i in 1:nobs){
dclass[i] ~ dcat(fc[1:nG, site[i]])
}#End i loop
for(j in 1:nsites){
#Construct cell probabilities for nG cells
for(k in 1:nG){
#Half-normal detection function at midpt (length of rectangle)
p[k,j] <- exp(- midpt[k] * midpt[k] / (2 * sigma[j] * sigma[j]))
#Probability of x in each interval (width of rectangle)
pi[k,j] <- v/B
#Detection probability for each interval (area of each rectangle)
f[k,j] <- p[k,j] * pi[k,j]
#Conditional detection probability (scale to 1)
fc[k,j] <- f[k,j] / pcap[j]
}#End k loop
#Detection probability at each site (sum of rectangles)
pcap[j] <- sum(f[1:nG,j])
#Observation process
y[j] ~ dbin(pcap[j], N[j])
#Description of latent number of groups (negative binomial)
N[j] ~ dpois(lambda.star[j])
#Expected Number of Groups
lambda.star[j] <- rho[j] * lambda[j]
#Overdispersion parameter for Expected Number of Groups
rho[j] ~ dgamma(r.N, r.N)
#Linear model for number of groups
lambda[j] <- exp(alpha[j] + log(offset[j]))
#Expected Group Size
gs.lam.star[j] <- gs.lam[j] * gs.rho[j]
#Overdispersion parameter for Expected Group Size
gs.rho[j] ~ dgamma(r.G, r.G)
#Group size
gs.lam[j] <- exp(beta)
}#End j loop
for(i in 1:nobs){
gs[i] ~ dpois(gs.lam.star[site[i]]) T(1,)
}#End i loop
##Derived quantities
#Number of groups within sampling boundary
Nin <- sum(N[1:nsites])
for(j in 1:nsites){
#Abundance at each transect
Ntotal[j] <- lambda.star[j] * gs.lam.star[j]
} #End j loop
#Abundance within sampling boundary
Nintotal <- sum(Ntotal[])
#Proportion of study region covered by sampling design
D <- (939.316/164.4837)
#Number of groups in entire study region
Nwinding <- Nin * D
#Abundance in entire study region
Nwindingtotal <- Nintotal * D
}