simuk.SBC#
- class simuk.SBC(model, num_simulations=1000, sample_kwargs=None, seed=None, data_dir=None)[source]#
Set up class for doing SBC.
- Parameters:
model (pymc.Model, bambi.Model or numpyro.infer.mcmc.MCMCKernel) – A PyMC, Bambi model or Numpyro MCMC kernel. If a PyMC model the data needs to be defined as mutable data.
num_simulations (int) – How many simulations to run
sample_kwargs (dict[str] -> Any) – Arguments passed to pymc.sample or bambi.Model.fit
seed (int (optional)) – Random seed. This persists even if running the simulations is paused for whatever reason.
data_dir (dict) – Keyword arguments passed to numpyro model, intended for use when providing an MCMC Kernel model.
Example
with pm.Model() as model: x = pm.Normal('x') y = pm.Normal('y', mu=2 * x, observed=obs) sbc = SBC(model) sbc.run_simulations() sbc.plot_results()
Methods