R/stanmodels.R

# Generated by rstantools.  Do not edit by hand.

# names of stan models
stanmodels <- c("cbqb", "cbqbv", "cbqd", "cbqdv", "cbqfixb", "cbqfixbv", "cbqfixd", "cbqfixdv", "cbqpanelb", "cbqpanelbv", "cbqpaneld", "cbqpaneldv", "cbqrandomb", "cbqrandombv", "cbqrandomd", "cbqrandomdv")

# load each stan module
Rcpp::loadModule("stan_fit4cbqb_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqbv_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqd_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqdv_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqfixb_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqfixbv_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqfixd_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqfixdv_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqpanelb_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqpanelbv_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqpaneld_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqpaneldv_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqrandomb_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqrandombv_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqrandomd_mod", what = TRUE)
Rcpp::loadModule("stan_fit4cbqrandomdv_mod", what = TRUE)

# instantiate each stanmodel object
stanmodels <- sapply(stanmodels, function(model_name) {
  # create C++ code for stan model
  stan_file <- if(dir.exists("stan")) "stan" else file.path("inst", "stan")
  stan_file <- file.path(stan_file, paste0(model_name, ".stan"))
  stanfit <- rstan::stanc_builder(stan_file,
                                  allow_undefined = TRUE,
                                  obfuscate_model_name = FALSE)
  stanfit$model_cpp <- list(model_cppname = stanfit$model_name,
                            model_cppcode = stanfit$cppcode)
  # create stanmodel object
  methods::new(Class = "stanmodel",
               model_name = stanfit$model_name,
               model_code = stanfit$model_code,
               model_cpp = stanfit$model_cpp,
               mk_cppmodule = function(x) get(paste0("model_", model_name)))
})

Try the cbq package in your browser

Any scripts or data that you put into this service are public.

cbq documentation built on April 3, 2023, 5:41 p.m.