Datasets

Generating datasets ready for use with SBC and working with them.

SBC_datasets()

Create new SBC_datasets object.

bind_datasets()

Combine multiple datasets together.

generate_datasets()

Generate datasets.

`[`(<SBC_datasets>)

Subset an SBC_datasets object.

SBC_generator_brms()

Create a brms generator.

SBC_generator_custom()

Wrap a function the creates a complete dataset.

SBC_generator_function()

Generate datasets via a function that creates a single dataset.

calculate_prior_sd()

Calculate prior standard deviation of a dataset

attribute_present()

Get attribute presence for a vector of variable names.

attribute_present_stats()

Check an attribute in the $stats element of the results for presence of an attribute.

combine_var_attributes()

Combine multiple sets of variable attributes.

remove_attribute_from_stats()

Remove an attribute from a data.frame column with attributes.

var_attributes() validate_var_attributes() possibly_constant_var_attribute() binary_var_attribute() hidden_var_attribute() na_valid_var_attribute() inf_valid_var_attribute() submodel_var_attribute()

Predefined constants to use for variable attributes recognized by SBC.

Backends

Represent various inference engines you can use with SBC.

SBC_backend_bridgesampling()

Backend using bridgesampling to do Bayes factor calculation (and Bayesian Model Averaging) over two candidate models.

SBC_backend_brms()

Build a backend based on the brms package.

SBC_backend_brms_from_generator()

Build a brms backend, reusing the compiled model from a previously created SBC_generator_brms object.

SBC_backend_cached()

A backend that wraps another backend with a caching scheme.

SBC_backend_cmdstan_sample()

Backend based on sampling via cmdstanr.

SBC_backend_cmdstan_variational()

Backend based on variational approximation via cmdstanr.

SBC_backend_default_thin_ranks()

S3 generic to get backend-specific default thinning for rank computation.

SBC_backend_extractBF_comparison()

A backend for Bayes factor workflow with BayesFactor::extractBF.

SBC_backend_function()

A backend that just calls a function.

SBC_backend_hash_for_cache()

Get hash used to identify cached results.

SBC_backend_iid_draws()

S3 generic to let backends signal that they produced independent draws.

SBC_backend_lmBF()

A backend using BayesFactor::lmBF()

SBC_backend_mock()

A mock backend.

SBC_backend_postprocess_cached_fit() SBC_backend_preprocess_fit_for_cache()

Allows the backend to do any pre-/post- processing on a fit stored to / loaded from cache.

SBC_backend_rjags()

Create a JAGS backend using rjags

SBC_backend_rstan_optimizing()

SBC backend using the optimizing method from rstan.

SBC_backend_rstan_sample()

SBC backend using the sampling method from rstan.

SBC_fit()

S3 generic using backend to fit a model to data.

SBC_fit_to_BFBayesFactor()

A fits need to implement this S3 generic to be useful for the SBC_backend_extractBF_comparison() backend.

SBC_fit_to_bridge_sampler()

Convert a fit for a given backend into a bridge sampler object.

SBC_fit_to_diagnostics()

S3 generic to get backend-specific diagnostics.

SBC_fit_to_draws_matrix()

S3 generic converting a fitted model to a draws_matrix object.

SBC_posterior_cdf()

Use a fitted model to obtain a posterior CDF at a given point.

Computation & results

Functions related to running the SBC computation and handling the results.

compute_SBC()

Fit datasets and evaluate diagnostics and SBC metrics.

SBC_results()

Create an SBC_results object

binary_calibration_from_bp() plot_binary_calibration_diff() plot_binary_calibration()

Binary prediction calibration computation and visualisation.

check_all_SBC_diagnostics()

Check diagnostics and issue warnings when those fail.

split_SBC_results_for_bf()

Split stats from SBC of Bayes factor into stats for the individual submodels.

`[`(<SBC_results>)

Subset the results.

bind_derived_quantities()

Combine two lists of derived quantities

derived_quantities()

Create a definition of derived quantities evaluated in R.

validate_derived_quantities()

Validate a definition of derived quantities evaluated in R.

compute_dquants()

Compute derived quantities based on given data and posterior draws.

bind_globals()

Combine two sets globals for use in derived quantities or backend

SBC_statistics_from_single_fit()

Recompute SBC statistics given a single fit.

recompute_SBC_statistics()

Recompute SBC statistics without refitting models.

bind_results()

Combine multiple SBC results together.

calculate_ranks_draws_matrix()

Calculate ranks given variable values within a posterior distribution.

SBC_fit_to_diagnostics()

S3 generic to get backend-specific diagnostics.

get_diagnostic_messages()

Get diagnostic messages for SBC_results or other objects.

default_chunk_size()

Determines the default chunk size.

default_cores_per_fit()

Determines the default cores per single fit.

binary_probabilities_from_stats()

Extract binary probabilities from SBC stats.

cached_fit_filename()

Provide a file where a cached result of a fit will be/was stored.

get_stats_for_submodel()

Extract stats for a submodel from a Bayes factor results

Plotting & Summarising

Plotting and summarising results

plot_ecdf() plot_ecdf_diff()

Plot the ECDF-based plots.

binary_calibration_from_bp() plot_binary_calibration_diff() plot_binary_calibration()

Binary prediction calibration computation and visualisation.

data_for_ecdf_plots()

Maybe not export in the end? Useful for debugging

plot_contraction()

Prior/posterior contraction plot.

plot_coverage() plot_coverage_diff()

Plot the observed coverage and its uncertainty.

plot_rank_hist()

Plot rank histogram of an SBC results.

plot_sim_estimated()

Plot the simulated "true" values versus posterior estimates

guess_rank_hist_bins()

Guess the number of bins for plot_rank_hist().

empirical_coverage()

Compute observed coverage of posterior credible intervals.

combine_all_variables() combine_array_elements()

Helper functions to be passed to ECDF-plots to combine variables in a single panel.

combine_args()

Combine two named lists and overwrite elements with the same name using the value from args2

combine_var_attributes()

Combine multiple sets of variable attributes.

gaffke_ci() gaffke_p() gaffke_test()

Non-parametric test for the mean of a bounded variable.

brier_resampling_test() brier_resampling_p() binary_miscalibration() miscalibration_resampling_p() miscalibration_resampling_test()

Binary calibration tests

Examples

Functions to let you easily test the pacakge

SBC_example_backend()

Construct a backend to be used in the examples.

SBC_example_generator()

Construct a generator used in the examples.

SBC_example_results()

Combine an example backend with an example generator to provide full results that can be used to test other functions in the package.

SBC_print_example_model()

Print the Stan code of a model used in the examples.

Miscellaneous

combine_args()

Combine two named lists and overwrite elements with the same name using the value from args2