-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodified_stancode.R
26 lines (21 loc) · 1.3 KB
/
modified_stancode.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
testevidence2 <- sample_n(evidence, size = 250, replace = FALSE)
stancode <- brms::make_stancode(site ~ s(lon, lat, bs = "gp", m = 3) + dem + temp + rain +
gp(distance_water) + frostdays + sunhours + tpi + slope,
family = bernoulli, data = testevidence2,
chains = 2, cores = 2, iter = 1000,
control = list(adapt_delta = 0.8,
max_treedepth = 13))
standata <- brms::make_standata(site ~ s(lon, lat, bs = "gp", m = 3) + dem + temp + rain +
gp(distance_water) + frostdays + sunhours + tpi + slope,
family = bernoulli, data = testevidence2,
chains = 2, cores = 2, iter = 1000,
control = list(adapt_delta = 0.8,
max_treedepth = 13))
# paste matern 32 covariance function in there
require(rstan)
require(StanHeaders)
brm_custom_1d <- rstan::stan_model("gp_matern_32.stan",
allow_undefined = TRUE,
includes = paste0('\n#include "', file.path(getwd(),'gp_matern_32_cov.hpp'), '"\n'))
brm_custom_1d <- rstan::stan_model("gp_matern_32.stan")
brm_custom <- rstan::sampling(brm_custom_1d, data = standata)