Datasets

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

bind_datasets()

Combine multiple datasets together.

generate_datasets()

Generate datasets.

SBC_datasets()

Create new SBC_datasets object.

`[`(<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

Backends

Represent various inference engines you can use with SBC.

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_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_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_mock()

A mock backend.

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_diagnostics()

S3 generic to get backend-specific diagnostics.

SBC_fit_to_draws_matrix()

S3 generic converting a fitted model to a draws_matrix object.

Computation & results

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

compute_SBC()

Fit datasets and evaluate diagnostics and SBC metrics.

check_all_SBC_diagnostics()

Check diagnostics and issue warnings when those fail.

SBC_results()

Create an SBC_results object

`[`(<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.

get_diagnostic_messages()

Get diagnostic messages for SBC_results or other objects.

SBC_fit_to_diagnostics()

S3 generic to get backend-specific diagnostics.

default_chunk_size()

Determines the default chunk size.

default_cores_per_fit()

Determines the default cores per single fit.

Plotting & Summarising

Plotting and summarising results

data_for_ecdf_plots()

Maybe not export in the end? Useful for debugging

plot_ecdf() plot_ecdf_diff()

Plot the ECDF-based plots.

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

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

wasserstein()

wasserstein distance between binned samples

cjs_dist()

Cumulative Jensen-Shannon divergence

combine_args()

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

max_diff()

Max difference between binned samples with the same length

rank2unif()

Distance between binned draws (rank for SBC) and discrete uniform

set2set()

Summarize relational property of overall prior and posterior draws