Skip to contents

Priors

Define the prior distribution over simulator parameters.

priors
Priors for neural simulation-based inference
prior_uniform()
Box-uniform (independent uniform) prior
prior_normal()
Independent normal prior
prior_lognormal() prior_exponential() prior_gamma() prior_beta() prior_student_t() prior_cauchy() prior_half_normal() prior_half_cauchy()
Named prior families
prior_independent()
Combine independent priors into one joint prior
prior_truncated()
Truncate a prior to a box
prior_custom()
Build a prior from arbitrary sampling / density functions
sample_prior()
Draw samples from a prior
within_support()
Test whether parameters lie within the prior support

Simulation and training

Generate training data and fit a neural posterior estimator.

simulate_for_sbi()
Run a simulator over prior draws
npe()
Neural Posterior Estimation (NPE)
npe_sequential()
Sequential NPE with truncated-prior proposals (TSNPE)
nle()
Neural Likelihood Estimation (NLE)
nre()
Neural Ratio Estimation (NRE)
save_npe() load_npe() save_nle() load_nle() save_nre() load_nre()
Save and reload a fitted model
density_estimator
Conditional density estimators
embedding_mlp()
Embedding (summary) networks for structured observations

Neural likelihood estimation

Learn a surrogate likelihood, sample it with MCMC, and export it to Stan.

log_lik()
Evaluate a surrogate likelihood
likelihood_fn()
A surrogate likelihood as a plain R function
posterior(<nsbi_nle>)
Posterior from a neural likelihood
sample(<nsbi_mcmc_posterior>)
Sample an MCMC posterior
nsbi_mcmc
MCMC over a learned likelihood
stan_code() write_stan_model() stan_data()
Export a learned likelihood to Stan

Neural ratio estimation

Learn the likelihood-to-evidence ratio with a classifier and sample it with MCMC.

log_ratio()
Evaluate a learned likelihood-to-evidence ratio
posterior(<nsbi_nre>)
Posterior from a neural ratio

Running the simulator

The simulator contract, parallel execution, and progress reporting.

nsbi_simulator
The simulator contract
nsbi_parallel
Running the simulator in parallel
nsbi_progress
Progress reporting

Working with the posterior

Condition on data, then sample, evaluate, and summarize.

posterior()
Posterior objects
sample()
Draw samples (S3 generic)
sample(<nsbi_posterior>)
Sample from a posterior
sample_posterior()
Sample from a posterior (non-generic alias)
log_prob()
Posterior log-density
map_estimate()
Maximum a posteriori (MAP) estimate
as.data.frame(<nsbi_samples>) summary(<nsbi_samples>) summary(<nsbi_posterior>) summary(<nsbi_npe>) summary(<nsbi_nle>) summary(<nsbi_nre>)
Summaries and tidy accessors

Diagnostics

Calibration and predictive checks for a fitted posterior.

diagnostics
Posterior diagnostics
sbc()
Simulation-Based Calibration (SBC)
expected_coverage()
Expected coverage of central credible intervals
tarp()
TARP expected coverage
c2st()
Classifier two-sample test (C2ST)
posterior_predictive()
Posterior predictive draws

Plotting

pairplot()
Visualize posterior samples
plot_sbc()
Plot an SBC rank histogram
plot_coverage()
Plot nominal vs. empirical credible-interval coverage
plot_tarp()
Plot TARP expected coverage
plot_posterior_predictive()
Plot posterior predictive checks

Benchmark tasks

Reference inference problems shared by the tests and benchmarks.