MMMPlotSuite.residuals_posterior_distribution#
- MMMPlotSuite.residuals_posterior_distribution(quantiles=None, aggregation=None)[source]#
Plot the posterior distribution of residuals.
Displays the distribution of residuals (true - predicted) across all time points and dimensions. Users can choose to aggregate across dimensions using mean or sum.
- Parameters:
- quantiles
listoffloat, optional Quantiles to display on the distribution plot. Default is [0.25, 0.5, 0.75]. Each value must be between 0 and 1.
- aggregation
str, optional How to aggregate residuals across non-chain/draw dimensions. Options: “mean”, “sum”, or None (default). - “mean”: Average residuals across date and other dimensions - “sum”: Sum residuals across date and other dimensions - None: Plot distribution for each dimension combination separately
- quantiles
- Returns:
- fig
matplotlib.figure.Figure The Figure object containing the subplots.
- axes
np.ndarrayofmatplotlib.axes.Axes Array of Axes objects corresponding to each subplot.
- fig
- Raises:
ValueErrorIf
y_original_scaleis not in posterior_predictive. Iftarget_datais not in constant_data. If any quantile is not between 0 and 1. If aggregation is not one of “mean”, “sum”, or None.
Examples
Plot residuals distribution with default quantiles:
mmm.plot.residuals_posterior_distribution()
Plot with custom quantiles and aggregation:
mmm.plot.residuals_posterior_distribution( quantiles=[0.05, 0.5, 0.95], aggregation="mean" )