BaseMMM.plot_prior_vs_posterior#
- BaseMMM.plot_prior_vs_posterior(var_name, alphabetical_sort=True, figsize=None)#
Plot the prior vs posterior distribution for a specified variable in a 3 columngrid layout.
This function generates KDE plots for each MMM channel, showing the prior predictive and posterior distributions with their respective means highlighted. It sorts the plots either alphabetically or based on the difference between the posterior and prior means, with the largest difference (posterior - prior) at the top.
- Parameters:
- var_name: str
The variable to analyze (e.g., ‘adstock_alpha’).
- alphabetical_sort: bool, optional
Whether to sort the channels alphabetically (True) or by the difference between the posterior and prior means (False). Default is True.
- figsize
tupleofint, optional Figure size in inches. If None, it will be calculated based on the number of channels.
- Returns:
- fig
plt.Figure The matplotlib figure object
- fig
- Raises:
ValueErrorIf the required attributes (prior, posterior) were not found.
ValueErrorIf var_name is not a string.