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
tuple
ofint
, 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:
ValueError
If the required attributes (prior, posterior) were not found.
ValueError
If var_name is not a string.