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:
- X
xr.Dataset,pd.DataFrame,pd.Series,np.ndarray New data for prediction. Can have a different
Tlength than the fitted data, enabling forecasting beyond the original time range.- extend_idatabool, optional
Whether to add the predictions to
self.idata. Defaults toTrue.- combinedbool, optional
Combine chain and draw dims into a single
sampledim. Defaults toTrue.- **sample_posterior_predictive_kwargs
Additional arguments passed to
pymc.sample_posterior_predictive().
- X
- Returns:
xr.DataArrayPosterior 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)