This class represents a Bayesian borrowing model using MCMC sampling. It inherits from the Model class.
Super class
Model -> MCMCModel
Public fields
stan_model_codeCode of the Stan model
stan_modelThe compiled Stan model
stan_model_nameName the Stan model is compiled under, for models that compile it only when they first sample
summary_variablesVariables to summarise from the posterior draws
fitThe MCMC fit object
fit_summarySummary of the Stan fit
treatment_effect_summarySummary statistics of the treatment effect posterior distribution
credible_interval_97.5The upper bound of the credible interval
credible_interval_2.5The lower bound of the credible interval
mcmc_configThe MCMC configuration parameters
mcmc_essMCMC ESS
n_divergencesNumber of divergences in MCMC inference
rhatr-hat statistics
draws_dirDirectory where to store MCMC draws (used by Stan)
prior_drawsDraws from the prior
prior_pdf_approxApproximation to the prior probability density function
prior_cdf_approxApproximation to the prior cumulative density function
posterior_pdf_approxApproximation to the posterior probability density function
posterior_cdf_approxApproximation to the posterior cumulative density function
Methods
Inherited methods
Model$calibrate_for_design()Model$check_data()Model$create()Model$empirical_bayes_update()Model$estimate_bayesian_operating_characteristics()Model$estimate_frequentist_operating_characteristics()Model$hypothesis_space_transformation()Model$inference_cache_scope()Model$plot_pdfs()Model$plot_posterior_pdf()Model$plot_prior_pdf()Model$posterior_beta_mixture()Model$posterior_mean()Model$posterior_moments()Model$posterior_quantile()Model$posterior_to_RBesT()Model$print_model_summary()Model$prior_elir_ess()Model$prior_to_RBesT()Model$simulation_for_given_treatment_effect()Model$test_decision()Model$vectorised_replicate_inference()
MCMCModel$new()
Initialize the MCMCModel object
A subclass that can also compute its posterior by quadrature declares
quadrature_available = TRUE and implements quadrature_posterior().
For such a class, mcmc_config$engine chooses between the two:
"quadrature", the default, or "stan". Every other subclass samples
with Stan whatever the setting.
Usage
MCMCModel$new(prior, mcmc_config)MCMCModel$stan_sampler()
The compiled Stan model, compiled on first use
A model that names its Stan program in stan_model_name rather than
compiling it in initialize() is compiled here, the first time it
samples. Models whose simulations never sample, because their replicates
go through a quadrature path, therefore never compile at all.
MCMCModel$quadrature_posterior()
The posterior as a grid, under the quadrature engine.
Subclasses with quadrature_available = TRUE must implement it.
Returns
A grid_posterior() list.
MCMCModel$quadrature_prior()
The prior as a grid, under the quadrature engine. Only needed by subclasses that sample their prior with Stan otherwise.
Returns
A grid_posterior() list.
MCMCModel$summary_rows()
Rows of the model summary, with the MCMC diagnostics of the last fit
The diagnostics are left out when the posterior is computed by quadrature.
MCMCModel$prepare_data()
Prepare the data for inference. Subclasses must implement the 'prepare_data' method.
MCMCModel$posterior_ess()
Effective sample sizes of the current posterior
The single summary pass over the draws already produced the posterior standard deviation and the credible interval bounds, so both effective sample sizes read straight off it. The inherited route would resample the draws and fit a mixture to the resample, which costs a mixture fit per replicate and adds a second layer of Monte Carlo error on top of the one the sampler already carries.
MCMCModel$compute_posterior_parameters()
Compute the posterior parameters. If there are posterior borrowing parameters, the following method must be overriden in the subclass.
MCMCModel$posterior_cdf()
Calculates the posterior cumulative distribution function (CDF) for a given target treatment effect.