-
Notifications
You must be signed in to change notification settings - Fork 1
/
GAM_run.R
77 lines (70 loc) · 1.62 KB
/
GAM_run.R
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
#########################################
### Run the spatio-temporal GAM model ###
#########################################
if (no_uncer == FALSE) {
## Fit the model
comm_comp_spatio_temporal_f <- gamm(
med_comp ~
## Spatial fixed
s(NATRGN, bs = "mrf", xt = xt) +
s(log(Density)) +
## Temporal fixed
s(temp) +
# s(month) +
s(year)
## Spatial random
, random = list(CNTY_NM = ~1)
## Other
, weights = 1 / var_comp
, method = "REML"
, data = comm_comp_summary_p2_m_dh)
## Fit the model
comm_comp_spatio_temporal_r <- gamm(
med_comp ~
## Spatial fixed
s(NATRGN, bs = "mrf", xt = xt) +
s(log(Density)) +
## Temporal fixed
s(temp) +
# s(month) +
s(year)
## Spatial random
, random = list(CNTY_NM = ~1)
## Other
, weights = 1 / var_comp
, method = "REML"
, data = comm_comp_summary_p2_well_observed_m_dh)
} else {
## Fit the model
comm_comp_spatio_temporal_f <- gamm(
med_comp ~
## Spatial fixed
# s(X, Y) +
s(NATRGN, bs = "mrf", xt = xt) +
s(log(Density)) +
## Temporal fixed
s(temp) +
# s(month) +
s(year)
## Spatial random
, random = list(CNTY_NM = ~1)
## Other
, method = "REML"
, data = comm_comp_summary_p2_m_dh)
## Fit the model
comm_comp_spatio_temporal_r <- gamm(
med_comp ~
## Spatial fixed
# s(X, Y) +
s(NATRGN, bs = "mrf", xt = xt) +
s(log(Density)) +
## Temporal fixed
s(temp) +
# s(month) +
s(year)
## Spatial random
, random = list(CNTY_NM = ~1)
## Other
, method = "REML"
, data = comm_comp_summary_p2_well_observed_m_dh)
}