-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_null.txt
91 lines (59 loc) · 4.21 KB
/
model_null.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
# NULL MODEL, NO EFFECTS ON ANY PARAMETERS
# Every 'site' will be a unique grid cell i.
# Every round t from 0 to maxT.
# Every visit v from 1 to maxV. THIS NEEDS TO BE REFERENCED PROPERLY WHEN CALCULATING THE MECHANISM OF N, y, and R!!!!!!
# constant lambda - mean initial deposition
# constant theta - mean subsequent *daily* deposition
# moose density estimated from ratio of theta to a fixed parameter per_moose_deposition supplied as data. Can make random later.
model
{
# Priors
p00 ~ dunif(0,1) # May need to make this informative if no information present
theta00 ~ dunif(-10,5) #prior for theta intercept
lambda0 ~ dunif(-10,5) #prior for lambda intercept
for(i in 1:nSites){
# Model for deposition ---------------------------------------------------------------------------------------------------------------------------------------
# This iteration of the model has a slightly different structure for N due to changes in simulation.
# Before, y_t ~ Bin(N_t-1, p)
# Now, y_t ~ Bin(N_t, p)
# Initial deposition is Poisson random, and occurs on June 1, 2016 (arbitrary selection, but is the first visit to any site).
N1[i] ~ dpois(lambda[i])
# Time 1 is visit 1, but indexed by 2, since we need to model the initial N. I choose to call that period before any visits time 0.
# Linear model for lambda. Include fixed/random effects here later
lambda[i] = exp(lambda0) # somewhat immaterial except for mechanistic model of deposition process and observation.
# Initial deposition of scats. There are no collections, and assumed to be no degradation until we visit, so N[i,1,v] is equal over all v.
for(v in 1:maxV){
N[i,1,v] = N1[i]
}
# Deposition between time 0 and first visit is found in days[i,1]
for(t in 1:(maxT - 1)){
R[i,t] ~ dpois(theta[i]*days[i,t]) # Every round has some added deposition after we leave. It is dependent upon the DAYS in between visits.
# For instance, R[i,2] ~ dpois(theta[i]*days[i,2]), where days[i,2] is the intervening time
}
# Linear model for theta. Include fixed/random effects here later
theta[i] = exp(theta00) # extend to include moose transect effect, spatial covariate effects. This is deposition per grid cell i, and therefore # moose will be calculated as per grid cell.
# Proceeding N's add new recruits and remove current counts from the previous time step's N.
# Recruits are random poisson variates with mean theta.
# Mechanism for scat removals/deposition ------------------------------------------------------------------------------------------
for(t in 2:maxT){
# First time going to a sampling unit what's there is what was there last time, minus what we picked up last time, plus what deposition happened last time.
N[i,t,1] = N[i,t-1,maxV] - y[i,t-1,maxV] + R[i,t-1]
# On subsequent visits within a sample occasion to a sampling unit, what's there is what was there after the first visit, minus what we picked up, all the way to maxV (20 in 2016).
for(v in 2:maxV){
N[i,t,v] = N[i,t,v-1] - y[i,t,v-1]
}
}
# Observation likelihood. Counts are conditional on population size at previous time step (after recruits and removals), and detection (which also depends on having visited the site). ------------------
for(t in 2:maxT){
for(v in 1:maxV){
# Homogeneous detection
p0[i,t,v] = p00
# adjust p0 such that those sites not visited are set to 0. Initially, all sites are p0[i,t] = 0.8
# vis is a matrix of binary indicators with '1' being 'visited', and '0' being 'not visited'. Multiply by p0 to fix 'not visited' sites to p = 0, and obtain a new matrix.
p[i,t,v] = p0[i,t,v] * vis[i,t,v]
y[i,t,v] ~ dbin(p[i,t,v], N[i,t,v])
}
}
#density[i] = (theta[i] / per_moose_deposition) / 2500 # density of moose per grid cell (50m x 50m = 2500m)
}
}