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:
ImpulsoModelNUTS sampler configuration for PyMC.
- Parameters:
- 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:
- 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
- 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.
- Raises:
RuntimeError – If the returned posterior is incomplete — an interrupted or failed nutpie run comes back as silently NaN-padded draws (see _raise_on_incomplete_draws).
- Return type:
InferenceData