Diff of /R/stanmodels.R [000000] .. [ede2d4]

Switch to unified view

a b/R/stanmodels.R
1
# Generated by rstantools.  Do not edit by hand.
2
3
# names of stan models
4
stanmodels <- c("base0", "base0_logit", "hs", "hs_logit")
5
6
# load each stan module
7
Rcpp::loadModule("stan_fit4base0_mod", what = TRUE)
8
Rcpp::loadModule("stan_fit4base0_logit_mod", what = TRUE)
9
Rcpp::loadModule("stan_fit4hs_mod", what = TRUE)
10
Rcpp::loadModule("stan_fit4hs_logit_mod", what = TRUE)
11
12
# instantiate each stanmodel object
13
stanmodels <- sapply(stanmodels, function(model_name) {
14
  # create C++ code for stan model
15
  stan_file <- if(dir.exists("stan")) "stan" else file.path("inst", "stan")
16
  stan_file <- file.path(stan_file, paste0(model_name, ".stan"))
17
  stanfit <- rstan::stanc_builder(stan_file,
18
                                  allow_undefined = TRUE,
19
                                  obfuscate_model_name = FALSE)
20
  stanfit$model_cpp <- list(model_cppname = stanfit$model_name,
21
                            model_cppcode = stanfit$cppcode)
22
  # create stanmodel object
23
  methods::new(Class = "stanmodel",
24
               model_name = stanfit$model_name,
25
               model_code = stanfit$model_code,
26
               model_cpp = stanfit$model_cpp,
27
               mk_cppmodule = function(x) get(paste0("model_", model_name)))
28
})