*! version 1.0.2 03jul2026

Copyright

Copyright 2026 Xuanyu Cai and Wenli Xu

Title

diddesign_plot -- Visualization for Double DID Results and Diagnostics

Syntax

diddesign_plot
[, options]

Plot Type
type(plottype) type of plot; default depends on source command

Output
saving(filename) save graph to file

name(string) name for graph window

replace allow overwriting existing file

Appearance
scheme(schemename) graph scheme

title(string) graph title

xtitle(string) x-axis title

ytitle(string) y-axis title

xlabel(axis_label) passthru to twoway xlabel(); overrides the auto-detected year axis on pattern plots

ylabel(axis_label) passthru to twoway ylabel(); overrides the hidden unit axis on pattern plots

ci show 90% SD-based bands around group-period mean outcomes on trends plot

band show CI as ribbon instead of error bars (estimates plot)

level(#) confidence level for estimates plot CI; default is level(90)

colorcheck distinguish placebo and DID estimates by color (estimates plot)

estcolor(colorname) color for DID estimates; default navy (requires colorcheck)

checkcolor(colorname) color for placebo estimates; default cranberry (requires colorcheck)

Data Sources
use_check(name) overlay placebo estimates from stored results

where plottype is one of estimates, trends, placebo, both, or pattern.

Description

diddesign_plot creates visualizations for Double DID estimation results
and diagnostic results. It can be run after diddesign or diddesign_check.
The command reads the stored estimation results from e() and generates
the appropriate plots.

The default plot type depends on the source command:

After diddesign: default is estimates

After diddesign_check: default is both

Five types of plots are available:

estimates - Double DID estimates across lead values with CI at specified level (default 90%, requires diddesign)

trends - Treatment and control group outcome trends over time (requires diddesign_check)

placebo - Placebo test results with standardized equivalence confidence intervals (requires diddesign_check)

both - Combined two-panel plot (requires diddesign_check)

pattern - Treatment timing pattern heatmap (SA design only, requires diddesign_check)

Options

Plot Type

type(plottype) specifies the type of plot to generate:

estimates shows Double DID estimates across lead values with 90% confidence
intervals. This is the default when run after diddesign.

trends shows outcome trends for treatment and control groups over time.
Available for standard DID designs only. Requires diddesign_check results.

placebo shows placebo test results with 95% standardized equivalence
confidence intervals. Requires diddesign_check results.

both combines two plots side by side. This is the default when run after
diddesign_check. For standard DID: placebo (left) + trends (right).
For SA design: placebo (left) + pattern (right).

pattern shows treatment timing pattern as a heatmap with units on the
y-axis and time on the x-axis. Units are sorted by treatment timing in
descending order (never-treated units at bottom, earliest-treated units at top).
Available for SA design only. Requires diddesign_check results.

Output

saving(filename) saves the graph to the specified file. Supported formats
include .png, .pdf, .eps, .svg, and .tif. If no extension is provided, .png is used.

replace allows overwriting an existing file.

name(string) specifies the name for the graph window.

Appearance

scheme(schemename) specifies the graph scheme.

title(string) specifies the graph title.

xtitle(string) specifies the x-axis title.

ytitle(string) specifies the y-axis title.

xlabel(axis_label) and ylabel(axis_label) pass their arguments directly
to twoway's xlabel()/ylabel(). On the pattern plot,
diddesign_plot auto-detects a calendar year axis from the caller's time()
variable when the time span matches the number of columns in e(Gmat); specifying
xlabel() explicitly overrides that default. When auto-detection is not applicable
(for example, on data where columns do not correspond to consecutive calendar periods),
a user-supplied xlabel() is required to produce a labelled axis.

ci shows 90% SD-based bands around group-period mean outcomes on the trends plot.

band displays confidence intervals as a shaded ribbon instead of error bars
on the estimates plot.

colorcheck enables two-color mode on the estimates plot when use_check()
is also specified. Placebo estimates (negative time) are drawn in one color and DID
estimates (positive time) in another, making the pre/post trajectory visually
distinct. The default colors are cranberry for placebo estimates and
navy for DID estimates. Without this option, all points are drawn in black.

estcolor(colorname) sets the color for DID estimates (positive time) when
colorcheck is specified. Any Stata color name or RGB specification is
accepted. Default is navy.

checkcolor(colorname) sets the color for placebo estimates (negative time)
when colorcheck is specified. Default is cranberry.

level(#) specifies the confidence level for the confidence intervals displayed
on the estimates plot. # must be between 1 and 99. The default is level(90),
which produces 90% confidence intervals. To obtain 95% confidence intervals,
specify level(95).

Data Sources

use_check(name) overlays placebo estimates from stored diddesign_check
results. The named results must have been saved using estimates store and
must use the same design, same outcome variable, same treatment variable, same
data type, same cluster variable, same covariate specification, and the same
if/in sample restriction as the current estimate. For panel
results, the stored diagnostic object must also use the same id()
variable and the same time() variable as the current estimate. For repeated
cross-section results, the stored diagnostic object must also use the same
post-treatment indicator variable, that is, the same post() definition,
as the current estimate. When specified,
placebo estimates (at negative time = -lag) are combined with estimation results
(at positive time = lead) to show the full pre- and post-treatment trajectory.

Methods and formulas

diddesign_plot generates visualizations based on stored e() results
from diddesign or diddesign_check.

Estimates plot

The estimates plot displays Double DID point estimates with confidence intervals
at the level specified by level() (default 90%). The plot is generated from
the e(estimates) matrix. The confidence intervals are computed as:

CI = estimate +/- z_{(1+level/100)/2} * SE

where z_{(1+level/100)/2} = invnormal((1 + level/100) / 2). For the default 90% CI,
this gives z_{0.95} = invnormal(0.95) = 1.645. For 95% CI, z_{0.975} = invnormal(0.975) = 1.960.
When the use_check() option is specified, placebo estimates from pre-treatment
periods are placed at negative time values (-lag) to create a complete trajectory.

Placebo plot

The placebo plot displays 95% standardized equivalence confidence intervals for
pre-treatment placebo estimates. The plot is generated from the e(placebo)
matrix. The equivalence CI is computed using the TOST (Two One-Sided Tests) method:

EqCI95 = (-nu, nu)

where nu = max(|estimate + z_{0.95} * SE|, |estimate - z_{0.95} * SE|). This
symmetric interval centered at zero indicates the range within which the true
effect lies with 95% confidence under the null hypothesis of no pre-trend.

Trends plot

The trends plot displays mean outcomes for treatment and control groups across
time periods relative to treatment assignment. The plot is generated from the
e(trends) matrix which contains group-time means, standard deviations,
and cell counts. When ci is specified, the command plots 90% confidence
bands using the stored group-period outcome standard deviation SD, matching
the reference DIDdesign R implementation. This plot is available for standard DID
designs only.

Pattern plot

The pattern plot displays treatment timing as a heatmap. Units are sorted by
their first treatment time in descending order, with never-treated units at the
bottom and earliest-treated units at the top. The plot is generated from the
e(Gmat) matrix. This plot is available for SA designs only.

Combined plot

The combined plot arranges two subplots side by side. For standard DID designs,
the placebo plot is displayed on the left and the trends plot on the right. For
SA designs, the placebo plot is displayed on the left and the pattern plot on
the right.

References

Egami, N. and S. Yamauchi. 2023.
Using Multiple Pretreatment Periods to Improve Difference-in-Differences
and Staggered Adoption Designs.
Political Analysis 31(2): 195-212.
https://doi.org/10.1017/pan.2022.8

Author

Xuanyu Cai

City University of Macau

xuanyuCAI@outlook.com

Wenli Xu

City University of Macau

wlxu@cityu.edu.mo

Also see

Online: diddesign, diddesign_check, diddesign_plot, diddesign_intro