BassModel.sample_posterior_predictive#

BassModel.sample_posterior_predictive(X, extend_idata=True, combined=True, **sample_posterior_predictive_kwargs)[source]#

Sample from the model’s posterior predictive distribution.

Parameters:
Xxr.Dataset, pd.DataFrame, pd.Series, np.ndarray

New data for prediction. Can have a different T length than the fitted data, enabling forecasting beyond the original time range.

extend_idatabool, optional

Whether to add the predictions to self.idata. Defaults to True.

combinedbool, optional

Combine chain and draw dims into a single sample dim. Defaults to True.

**sample_posterior_predictive_kwargs

Additional arguments passed to pymc.sample_posterior_predictive().

Returns:
xr.DataArray

Posterior predictive samples.

Examples

In-sample (same number of time points, different t):

pp = model.sample_posterior_predictive(X=new_t_data)

Out-of-sample forecast (future time points):

future = xr.Dataset({"T": np.arange(20, 30)})
pp = model.sample_posterior_predictive(X=future)

Extended window (past + future):

extended = xr.Dataset({"T": np.arange(30)})
pp = model.sample_posterior_predictive(X=extended)