-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_stan.R
34 lines (26 loc) · 907 Bytes
/
test_stan.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
# Script for quickly testing Stan and whether we can compile models on this system
library(rstan)
message('== Stan self-test ==')
message('Quick compilation test...')
example(stan_model, package = "rstan", run.dontrun = TRUE)
# workaround...
Sys.setenv(PKG_LIBS = Sys.getenv("LOCAL_LIBS"))
example(stan_model, package = "rstan", run.dontrun = TRUE)
message('Trying to compile Stan model...')
cmod2 = stan_model(
file = file.path(getwd(), 'models', 'gmm.stan'),
allow_undefined = TRUE,
auto_write = TRUE,
save_dso = TRUE,
verbose = TRUE
)
message('Trying to compile stan model with external code...')
cmod = stan_model(
file = file.path(getwd(), 'loglik', 'gmm_full_diag_mloglik_z.stan'),
allow_undefined = TRUE,
auto_write = TRUE,
save_dso = TRUE,
verbose = TRUE,
includes = sprintf('\n#include "%s"\n', file.path(getwd(), 'loglik', 'get_iter.hpp'))
)
message('Looks good!')