Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(bsl_run_diagnostics)
export(bsl_summarise_posteriors)
export(bsl_to_mcmc_list_multi)
export(check_coverage)
export(compile_stan_model)
export(compute_iqd)
export(compute_median_bias)
export(compute_pathogen_model_bayes_factors)
Expand Down
29 changes: 29 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,35 @@ gamma_type2_reliable <- function(datasets,
}


# Compile Stan model -------------------------------------------------------

#' Compile a ddsynth Stan model
#'
#' Compiles and returns one of the Stan models shipped with the package.
#' Pass the returned object to [pre_inference_checks()], [fit_model()], or
#' [run_simulation_study_generalized()].
#'
#' @param model Character string: `"factorised"` (default) uses the
#' order-statistic factorised likelihood
#' (`hierarchical_data_synthesis_summary_stats.stan`); `"joint"` uses the
#' joint parameterisation
#' (`hierarchical_data_synthesis_summary_stats_joint.stan`).
#' @return A compiled `stanmodel` object.
#' @export
compile_stan_model <- function(model = c("factorised", "joint")) {
model <- match.arg(model)
filename <- switch(model,
factorised = "hierarchical_data_synthesis_summary_stats.stan",
joint = "hierarchical_data_synthesis_summary_stats_joint.stan"
)
stan_file <- system.file("stan", filename, package = "ddsynth")
if (!nzchar(stan_file)) {
stop("Stan model file '", filename, "' not found in ddsynth installation.")
}
rstan::stan_model(stan_file)
}
Comment thread
cm401 marked this conversation as resolved.


# Pre-inference checks -----------------------------------------------------

#' Run pre-inference checks on a list of datasets
Expand Down
Loading
Loading