-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFitWarblerModel.R
More file actions
56 lines (47 loc) · 1.49 KB
/
FitWarblerModel.R
File metadata and controls
56 lines (47 loc) · 1.49 KB
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
# library(raster)
library(INLA)
# load model-fitting function
source("Functions/FitModel.R")
# load INLA stacks created in MakeStacks.R
load("Data/Stacks.RData")
# create priors
C.F. <- list(
mean = list(int.BBS = 0, int.eBird = 0, int.BBA = 0),
mean.intercept = 0,
prec = list(int.BBS = 1, int.eBird = 1, int.BBA = 1),
prec.intercept = 0.001
)
# The parameters "prior.range" and "prior.sd" control the joint prior on range
# and standard deviation of the spatial field. See here for details:
# https://groups.google.com/d/msg/r-inla-discussion-group/dunoXK_yAco/JhmYb5JoAQAJ
# e.g.: c(0.01, 0.05) means a 5% that the range will be less than 0.01
# specific notes: "it is advisable not to favour ranges that are smaller than
# the resolution of the mesh" "At this point I think one has to do some
# experimenting with the priors. As far as I know, we still do not have enough
# experience with the priors to come up with clearer guidelines"
spde <- inla.spde2.pcmatern(
mesh = Mesh$mesh,
alpha = 2,
prior.range = c(0.02, 0.5),
prior.sigma = c(5, 0.1)
)
form <- formula(
resp ~ 0 + elevation + canopy +
Intercept + X + Y + int.BBS +
pop.density + int.eBird + int.BBA +
f(i, model = spde)
)
warbler_model <- FitModel(
stk.ip, stk.BBS, stk.BBA, stk.eBird, stk.pred$stk,
formula = form,
CovNames = NULL,
mesh = Mesh$mesh,
predictions = TRUE,
control.fixed = C.F.,
waic = TRUE,
nthreads = 16
)
save(
C.F., spde, form, warbler_model,
file = "Data/WarblerModelOutput.RData"
)