*! version 1.0.0 11jul2026

Title

pidid -- Path-Integrated Difference-in-Differences (PI-DiD) estimator

Syntax

pidid depvar [if] [in] ,
panelvar(varname)
timevar(varname)
treatvar(varname)
t0(#)
[t1(#) graph notable
xtitle(string) ytitle(string)
title(string) name(string)]

Required
panelvar(varname) unit (id) identifier

timevar(varname) calendar/period variable

treatvar(varname) time-invariant 0/1 treatment-group indicator

t0(#) baseline period (start of the post-treatment window)

Optional
t1(#) evaluation horizon (endline); default is the maximum
observed value of timevar

graph draw the treated vs. counterfactual paths with the
cumulative-effect area shaded

notable suppress the period-by-period c0(t)/c1(t)/tau(t) table

xtitle(string) graph x-axis title

ytitle(string) graph y-axis title

title(string) graph title

name(string) graph name, passed to name()

Description

pidid implements the Path-Integrated Difference-in-Differences
framework: instead of comparing treated and control outcomes at a single
endline date, it treats the treatment effect as a trajectory

tau(t) = c1(t) - c0(t)

where c1(t) and c0(t) are the (group-mean) treated and control outcome
paths over time, and integrates this gap over the post-treatment window
[t0, t1] using the trapezoidal rule to obtain the cumulative causal
effect

sigma = INTEGRAL_t0^t1 tau(t) dt

and the path-integrated Average Treatment Effect on the Treated,
tau-bar = sigma / (t1 - t0). For comparison, pidid also reports the
conventional static two-period DiD estimate, tau(t1) - tau(t0), which is
computed only from the endpoints and can be zero (or misleadingly small)
whenever a transitory intervention's effect has fully decayed by t1, even
though sigma remains strictly positive. See Salavi (2026) for the
underlying theory and the endpoint-subtraction-bias result.

pidid works with panel or repeated cross-section data: it first
collapses depvar to group-by-time means (control vs. treated) via
collapse, so panelvar does not need to be balanced across
periods.

Options

panelvar(varname) identifies the individual/unit. It is used only
for sample validation; it need not be balanced.

timevar(varname) is the calendar-time or period variable over which
the trajectory is observed.

treatvar(varname) must be a time-invariant indicator equal to 1 for
treated units and 0 for control units.

t0(#) is the reference/baseline period marking the start of the
integration window. Under parallel pre-trends, tau(t0) should be
approximately zero; pidid reports tau(t0) as a diagnostic.

t1(#) is the terminal evaluation date (endline). If omitted, it
defaults to the last period observed in the data. Setting t1() to an
intermediate rejoining date t2 recovers the full, horizon-invariant
cumulative effect described in the paper.

graph produces a twoway plot of c0(t) and c1(t) with the region
between them, over [t0, t1], shaded to represent sigma.

notable suppresses the printed c0(t)/c1(t)/tau(t) table (results are
still returned in r()).

Stored results

pidid stores the following in r():

Scalars

r(sigma) cumulative causal effect

r(att_path) path-integrated ATT (sigma / (t1-t0))

r(did_static) conventional static DiD, tau(t1) - tau(t0)

r(tau_t0) pre-treatment gap at t0 (parallel-trends check)

r(t0) baseline period used

r(t1) endline period used

Examples

Setup: a two-"individual" panel representing group means, replicating the
worked example in Salavi (2026) -- a training program whose earnings premium
fully decays by year 5.

. clear

. input id time treat earnings

1 0 0 50000

1 1 0 52000

1 2 0 54000

1 3 0 56000

1 4 0 58000

1 5 0 60000

2 0 1 50000

2 1 1 62000

2 2 1 61000

2 3 1 59000

2 4 1 58500

2 5 1 60000

end

Path-integrated estimate and graph:

. pidid earnings, panelvar(id) timevar(time) treatvar(treat) t0(0) t1(5) graph

This returns sigma = 20,500, tau-bar = 4,100/year, and a static DiD of 0 --
showing exactly how a static endline comparison hides a real, sizeable
cumulative benefit.

References

Salavi, C. A-F. 2026. "Path-Integrated Difference in Difference (PI-DiD)
Framework." Working paper, African School of Economics.

Author

Command implementation based on the PI-DiD framework proposed in the
paper above.