StaggeredDifferenceInDifferences.plot_group_time#

StaggeredDifferenceInDifferences.plot_group_time(*, 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:
  • hdi_prob (float | None) – Probability mass of the highest density interval shown by the uncertainty bands. As with plot(), Bayesian ATT(g, t) bounds are cached during effect aggregation. If supplied here, the value must match the cached hdi_prob_; otherwise a ValueError is raised. Pass None (the default) to plot using the cached 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".

  • 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]]