Skip to content

Commit

Permalink
included some stan model type asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
n8thangreen committed Aug 12, 2024
1 parent ad9a9ba commit 4001331
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions R/bmcm_stan.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,27 @@ load_precompiled_model <- function(use_cmdstanr, path) {
}

#
perform_sampling <- function(use_cmdstanr, precompiled_model,
perform_sampling <- function(use_cmdstanr, stan_model,
stan_inputs, dots) {
if (use_cmdstanr) {

if (!inherits(stan_model, "CmdStanModel")) {
stop("The 'stan_model' argument must be a CmdStanModel object.")
}

output <- do.call(
precompiled_model$sample,
stan_model$sample,
args = c(stan_inputs, dots)
)
} else {

if (!inherits(stan_model, "stanmodel")) {
stop("The 'stan_model' argument must be a stanmodel object.")
}

output <- do.call(
rstan::sampling,
args = c(list(object = precompiled_model),
args = c(list(object = stan_model),
stan_inputs, dots)
)
}
Expand Down

0 comments on commit 4001331

Please sign in to comment.