aimz.ImpactModel.set_posterior_sample#

ImpactModel.set_posterior_sample(posterior_sample)[source]#

Set posterior samples for the model.

This method sets externally obtained posterior samples on the model instance, enabling downstream analysis without requiring a call to fit() or fit_on_batch().

It is primarily intended for workflows where posterior sampling is performed manually—for example, using NumPyro’s SVI (or MCMC) with the Predictive API—and the resulting posterior samples are injected into the model for further use.

Internally, batch_ndims is set to 1 by default to correctly handle the batch dimensions of the posterior samples. For more information, refer to the NumPyro documentation.

Parameters:

posterior_sample (dict[str, Array]) – Posterior samples to set for the model.

Returns:

The model instance, treated as fitted with posterior samples set, enabling method chaining.

Raises:

ValueError – If the batch shapes in posterior_sample are inconsistent.

Return type:

Self