NUTSSampler#

class impulso.samplers.NUTSSampler(*, draws=1000, tune=1000, chains=4, cores=None, target_accept=0.8, random_seed=None, nuts_sampler=<factory>, progressbar=<factory>, nuts_sampler_kwargs=None)[source]#

Bases: ImpulsoModel

NUTS sampler configuration for PyMC.

Parameters:
draws#

Number of posterior draws per chain.

Type:

int

tune#

Number of tuning steps per chain.

Type:

int

chains#

Number of independent chains.

Type:

int

cores#

Number of CPU cores. None = auto-detect.

Type:

int | None

target_accept#

Target acceptance rate for NUTS.

Type:

float

random_seed#

Random seed for reproducibility.

Type:

int | None

nuts_sampler#

NUTS backend. Auto-detects nutpie if installed.

Type:

Literal[‘pymc’, ‘nutpie’]

progressbar#

Show the sampler progress bar. Defaults to True, but off during documentation builds (IMPULSO_DOCS_BUILD=1).

Type:

bool

nuts_sampler_kwargs#

Extra keyword arguments forwarded verbatim to the NUTS backend (pm.sample(nuts_sampler_kwargs=…)). Useful for backend-specific adaptation options — e.g. nutpie’s low_rank_modified_mass_matrix=True, which handles the ill-conditioned posteriors that arise in large VARs with many near-collinear lag regressors, where diagonal mass-matrix adaptation mixes poorly.

Type:

dict | None

Expand for references to impulso.samplers.NUTSSampler

The conjugate VAR: fast Bayesian estimation / When to reach for ConjugateVAR instead of the NUTS VAR / Scope

Probabilistic Forecasts

Identification in structural VARs: Cholesky vs sign restrictions / A case study using U.S. monetary policy data / Impulse Response Function

Oil supply news with an external instrument / How the announcement surprise identifies one shock

Fitting Your First Bayesian VAR

Stochastic volatility: modelling time-varying uncertainty / Why time-varying volatility matters

Structural Shocks in the Atmosphere

model_config = {'frozen': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

sample(model)[source]#

Run NUTS sampling on the given PyMC model.

Parameters:

model (Model) – A fully specified PyMC model.

Returns:

ArviZ InferenceData with posterior and log_likelihood groups.

Return type:

InferenceData