SyntheticDifferenceInDifferences.plot#

SyntheticDifferenceInDifferences.plot(*, round_to=None, ci_prob=0.94, hdi_prob=None, kind='ribbon', ci_kind='hdi', num_samples=50, show=True, legend_kwargs=None)[source]#

Plot SDiD results: counterfactual, period impact, and cumulative impact.

Parameters:
  • round_to (int | None) – Number of decimals used to round the ATT in the title. Defaults to 2. Use None for raw values.

  • ci_prob (float) – Probability mass of the highest density interval drawn around the posterior predictive, causal impact, and cumulative impact bands. Must be in (0, 1]. Defaults to HDI_PROB (currently 0.94).

  • hdi_prob (float | None) – Deprecated. Use ci_prob instead.

  • kind (Literal['ribbon', 'histogram', 'spaghetti']) – How posterior uncertainty is rendered via plot_posterior_over_x(). Defaults to "ribbon". For "spaghetti", legends use draw lines rather than a shaded band. For "histogram", uncertainty is shown as a 2D density heatmap with a mean line overlay (no ribbon patch for legends).

  • ci_kind (Literal['hdi', 'eti']) – Credible interval type when kind="ribbon". Defaults to "hdi".

  • num_samples (int) – Number of posterior draws when kind="spaghetti". Defaults to 50. Ignored for other kinds.

  • show (bool) – Whether to call matplotlib.pyplot.show() after drawing. Defaults to True.

  • legend_kwargs (dict[str, Any] | None) – Keyword arguments applied to the top-axis legend in place after the figure is built. Supported keys include loc, bbox_to_anchor, fontsize, frameon, title, and optionally bbox_transform alongside bbox_to_anchor. See _render_plot().

Returns:

  • fig (matplotlib.figure.Figure) – The figure containing the three stacked panels.

  • ax (numpy.ndarray) – Array of the three matplotlib.axes.Axes instances.

Return type:

tuple[Figure, ndarray]