didintjl_plot

didintjl_plot

Produces parallel trends plots and event study plots to help assess which DID-INT model variation to use.
Based on Karim & Webb (2025) https://arxiv.org/abs/2412.14447.

Command Description

didintjl_plot is a Stata command that wraps the didint_plot() function
from the DiDInt.jl Julia package. It produces either parallel trends plots (one panel per DID-INT model variation)
or event study plots with confidence intervals. It is recommended to run
didintjl_plot prior to didintjl to guide model selection.

Requirements

didintjl_plot and didintjl are tested and designed for the following versions:

Requirement

Julia version 1.12.0 or later

Stata version 16 or later

julia.ado version 2.0.0 or later (https://github.com/droodman/julia.ado)

DiDInt.jl version 0.9.6 or later (https://github.com/ebjamieson97/DiDInt.jl)

To install julia.ado, run:

. ssc install julia

To install DiDInt.jl, run:

. jl AddPkg DiDInt

Syntax

didintjl_plot
,
outcome(varname)
state(varname)
time(varname)

[gvar(varname)
treated_states(string)
treatment_times(string)
date_format(string)
covariates(string)
ccc(string)
weights(integer)
ref_column(string)
ref_group(string)
freq(string)
freq_multiplier(integer)
start_date(string)
end_date(string)
hc(integer)
event(integer)
ci(real)
groupmin(integer)
window(numlist)
process(integer)]

Parameters

Required
outcome(varname) name of outcome variable

state(varname) name of state identifier variable

time(varname) name of time variable

Treatment Specification
gvar(varname) variable indicating time of first treatment for each state

treated_states(string) list of treated states (use with treatment_times)

treatment_times(string) list of treatment times (use with treated_states)

Date Options
date_format(string) format of time variable, start_date, end_date, and treatment_times

Period Grid Construction (Staggered Adoption Only)
freq(string) time period frequency: "year", "month", "week", or "day"; triggers date matching procedure

freq_multiplier(integer) multiplier for freq (default: 1); e.g., 2 for two-year periods. Has no effect unless used with freq.

start_date(string) starting date for the period grid construction

end_date(string) ending date for the period grid construction

Covariates
covariates(varnames or string) space-separated list of covariate names

ref_column(string) column name for categorical reference variable

ref_group(string) reference group for categorical variable (requires ref_column)

CCC and Weighting
ccc(string) space-separated list of DID-INT model variations to plot: any combination of "hom", "time", "state", "add", "int", or "none". Defaults to all six when not specified.

weights(integer) apply weighting when computing event plot estimates (0 = false, 1 = true, default: 1)

Plot Options
event(integer) plot type: 0 = parallel trends plot, 1 = event study plot (default: 0)

ci(real) confidence level for event study confidence intervals (default: 0.95)

groupmin(integer) minimum number of groups required to display confidence intervals in event study plot; observations with fewer groups than this threshold have their confidence intervals suppressed (default: 3)

window(numlist) two-element numlist specifying the range of periods to display. For parallel trends plots (event(0)), specifies the period number range. For event study plots (event(1)), specifies the range of periods relative to treatment (e.g., window(-5 5))

Inference
hc(integer) heteroskedasticity-consistent standard error type (default: 1)

Data Processing
process(integer) automatic processing of labeled covariate variables before passing to Julia (0 = off, 1 = on, default: 1).
When enabled, any covariate with a value label attached is decoded and then tested for numeric conversion.
If all decoded values are numeric, the value label is stripped and the variable is passed as numeric.
If the decoded values contain non-numeric characters (e.g. occupation or race category names), the variable is converted from a labeled numeric to a string and passed as a string categorical.
A warning message is displayed for each variable that is converted. Set process(0) to skip this conversion and pass all variables as-is. By default, any labelled variables are passed
from Stata to Julia as categorical variables, however this may not always be desired (e.g. the case of a labelled numeric variable). This argument attempts to rectify this potential issue.

Examples

For more examples, including an example dataset and do-file, please visit the GitHub repository:

https://github.com/ebjamieson97/didintjl

Parallel trends plot for a subset of states and two CCC specifications:

. use "MeritExampleDataDiDIntjl.dta", clear

. * Subset to four states to avoid a cluttered plot

. keep if inlist(state, "34", "71", "11", "14")

. didintjl_plot, outcome("coll") state("state") time("year") ///

treatment_times("2000 1991") date_format("yyyy") ///

covariates("asian male black") ccc("hom int")

This produces a side-by-side parallel trends plot with one panel per 'ccc' specification (DID-INT model variations),
with dashed vertical lines marking treatment times. Inspecting how trends evolve before
treatment under different specifications helps guide the choice of ccc() in
didintjl.

Event study plot using gvar():

. use "MeritExampleDataDiDIntjl.dta", clear

. gen year_numeric = real(year)

. bysort state (year_numeric): egen gvar = min(cond(merit == 1, year_numeric, .))

. didintjl_plot, outcome(coll) state(state) time(year_numeric) gvar(gvar) ///

date_format("yyyy") covariates("asian male black") event(1)

Specifying event(1) produces event study plots across all CCC specifications,
showing point estimates and confidence interval bands as a function of time relative
to treatment. A dotted vertical line marks period 0 (treatment onset) and a horizontal
line marks zero.

Plot Types

didintjl_plot produces two types of plots depending on the event() option:

event() Value

0 Parallel trends plot (default). Produces one panel per 'ccc' specification, showing
the covariate-adjusted outcome over time for each state. Dashed vertical lines mark treatment
times. Useful for visually assessing whether pre-treatment trends are parallel across states.

1 Event study plot. Produces one panel per 'ccc' specification, showing the
mean outcome (while controlling for covariates depending on each 'ccc' specification)
at each period relative to treatment, along with a confidence interval band.
Periods with fewer groups than groupmin() have their confidence intervals suppressed.

CCC Options

The ccc() option accepts a space-separated list of model specifications to plot simultaneously.
Each named specification produces its own panel in the combined graph. Valid values are:

CCC Option

hom Homogeneous DID-INT.

state State-varying DID-INT.

time Time-varying DID-INT.

add Two one-way DID-INT.

int Two-way DID-INT.

none No covariates included.

When ccc() is not specified, all six specifications are plotted. Specifying a subset
(e.g., ccc("hom int")) restricts the output to only those panels, which can reduce
clutter when only certain specifications are of interest.

For guidance on model selection, see Karim and Webb (2025) https://arxiv.org/abs/2412.14447 (perhaps especially sections 8 & 9).

Date Format Compatibility

didintjl_plot is compatible with the same date formats as didintjl.
The time() variable can be a string in any of the following formats, as long as
date_format() is specified appropriately:

Format

"yyyy/mm/dd" Example: 1997/08/25

"yyyy-mm-dd" Example: 1997-08-25

"yyyymmdd" Example: 19970825

"yyyy/dd/mm" Example: 1997/25/08

"yyyy-dd-mm" Example: 1997-25-08

"yyyyddmm" Example: 19972508

"dd/mm/yyyy" Example: 25/08/1997

"dd-mm-yyyy" Example: 25-08-1997

"ddmmyyyy" Example: 25081997

"mm/dd/yyyy" Example: 08/25/1997

"mm-dd-yyyy" Example: 08-25-1997

"mmddyyyy" Example: 08251997

"mm/yyyy" Example: 08/1997

"mm-yyyy" Example: 08-1997

"mmyyyy" Example: 081997

"yyyy" Example: 1997

"ddmonyyyy" Example: 25aug1997

"yyyym00" Example: 1997m8

Ensure that the format specified in date_format() exactly matches how dates appear
in your time() variable. Note that if the time() variable is simply a 4-digit year,
the date_format() argument does not need to be specified.

Important: The time() variable must be of the same type as either the treatment_times()
values or the gvar() variable depending on which argument is specified. This means:

- If using treatment_times(), the time() variable and dates specified in treatment_times()
must both be identically formatted strings matching one of the compatible date formats above

- If using gvar(), both time() and gvar() should either both be numeric variables or both be string variables of the same format

Further Reading

For a deeper dive into the backend implementation, see the DiDInt.jl package documentation:

https://ebjamieson97.github.io/DiDInt.jl/stable/details/

Package Author

Eric Jamieson. Tell me about all the bugs in my code: ericbrucejamieson@gmail.com or at https://github.com/ebjamieson97/didintjl.

Citations

If you use didintjl_plot in your research, please cite:

Sunny Karim and Matthew D. Webb. "Good Controls Gone Bad: Difference-in-Differences with Covariates."
https://arxiv.org/abs/2412.14447