StaggeredDifferenceInDifferences.plot_group_time#

StaggeredDifferenceInDifferences.plot_group_time(*, group='posterior', hdi_prob=None, layout='facet', x_axis='event_time', include_placebo=True, figsize=None, show=True, legend_kwargs=None)[source]#

Plot cohort-specific ATT(g, t) trajectories.

Parameters:
  • group (Literal['prior', 'posterior']) – Which draw group to plot. "prior" renders a single-panel prior predictive check and requires sample_prior_predictive(); "posterior" (default) renders the cohort trajectories and requires fit().

  • hdi_prob (float | None) – Probability mass of the highest density interval. Posterior ATT(g, t) bounds are fixed during effect aggregation, so an explicit value must match result.hdi_prob or a ValueError is raised. For group="prior", this controls the counterfactual band computed at plot time. Pass None (the default) to use the selected bundle’s stored value. Ignored for OLS models.

  • layout (Literal['facet', 'overlay']) – Plot layout. "facet" draws one row per cohort and "overlay" draws all cohorts on a single axes. Defaults to "facet".

  • x_axis (Literal['event_time', 'calendar_time']) – Time scale for the cohort trajectories. "event_time" plots each cohort against periods since treatment, giving an ATT(g, e) view derived from ATT(g, t). "calendar_time" plots each cohort against calendar time t. Defaults to "event_time".

  • include_placebo (bool) – Whether to include pre-treatment residual estimates for eventually-treated cohorts as placebo diagnostics. Defaults to True.

  • figsize (tuple[float, float] | None) – Width and height of the figure in inches, passed to matplotlib.pyplot.subplots(). Defaults to a height scaled by the number of cohorts when layout="facet" and (10, 6) when layout="overlay". For group="prior", the default single-panel figure size is (10, 4).

  • show (bool) – Whether to automatically display the plot. Defaults to True.

  • legend_kwargs (dict[str, Any] | None) – Keyword arguments to adjust legend placement and styling. Supported keys: loc, bbox_to_anchor, fontsize, frameon, title (bbox_transform is accepted alongside bbox_to_anchor). The existing legend is modified in place so that custom handles are preserved.

Returns:

  • fig (matplotlib.figure.Figure) – The figure that was created.

  • ax (list[matplotlib.axes.Axes]) – Axes containing the cohort trajectories. The list has one axes per cohort when layout="facet" and one axes when layout="overlay".

Return type:

tuple[Figure, list[Axes]]