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()orfit_on_batch().It is primarily intended for workflows where posterior sampling is performed manually—for example, using NumPyro’s
SVI(orMCMC) with thePredictiveAPI—and the resulting posterior samples are injected into the model for further use.Internally,
batch_ndimsis set to1by 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_sampleare inconsistent.- Return type: