*! version 2.1 2/23/2023

csdid postestimation: Post-estimation utilities for CSDID

Aggregations and Pretrend testing

There are two commands that can be used as post estimation tools. These are csdid_estat and csdid_stats.
Both can be used to obtain similar statistics. The first one, csdid_estat, works when using
estat, after the model estimation via csdid.

The second one csdid_stats works similarly but when using the "saved" RIF file. It can be used to produce
wild Bootstrap SE.

Below the syntax for both commands is discussed.

Syntax

estat [subcommand], [options]

csdid_stats [subcommand], [options]

Subcommands

Subcommands

pretrend Estimates the chi2 statistic of the null hypothesis that ALL pretreatment ATTGT's are
statistically equal to zero.

pretrend, window(#1 #2) Estimates the chi2 statistic of the null hypothesis that ALL pretreatment ATTGT's within window are
statistically equal to zero.

Aggregation subcommands.

simple Estimates the ATT for all groups across all periods.

group Estimates the ATT for each group or cohort, over all periods

calendar Estimates the ATT for each period, across all groups or cohorts

event Estimates the dynamic ATT's. ATT's are estimated using all periods relative to the
period of the first treatment, across all cohorts.

event, window(#1 #2) Same as above, but request only events between #1 and #2 to be estimated.

cevent, window(#1 #2) Estimates Censored Event averages. It estimates the average across all ATTGT's that correspond
to periods between T#1 and T#2, inclusive. For example estat cevent , window(0 0) simply reproduces the effect at T+0.

all Produces all aggregations. Not available with csdid_stats. And cannot be combined with estore() nor esave()

attgt Produces the ATTGT's.

options

estore(name) When using any of the 4 types of aggregations, request storing the outcome in memory as name

esave(name) When using any of the 4 types of aggregations, request saving the outcome in disk.

replace Request to replace ster file, if the a file already exists.

post Request posting the results in e().

save Request saving the RIF associated with the requested aggregation as a variable in the file. They can be used to produce other aggregations based on the RIFs See example.

Standard Error Options

By default, csdid_estat and csdid_stats produce asymptotic standard errors.

Using csdid_estat or estat subcommand always produces asymptotic standard errors, even if csdid
was estimated requesting Wbootstrap standard errors.

To produce Wbootstrap Standard errors, for other aggregations, you need to use the saved RIF-file, and csdid_stats

csdid_stats can produce Wbootstrap standard if requested, using the following options:

SE options

wboot Request Estimation of Standard errors using a multiplicative WildBootstrap procedure.
The default uses 999 repetitions using mammen approach.

wboot(reps(#)) Specifies the number of repetitions to be used for the Estimation of the WBoot SE. Default is 999

wboot(wtype(type)) Specifies the type of Wildbootstrap procedure. The default is "mammen", but "rademacher" is also
avilable.

rseed(#) Specifies the seed for the WB procedure. Use for replication purposes.

csdid_plot: Plots after csdid, csdid_estat and csdid_stats

csdid also comes with its own command to produce simple plots for all aggregations. It automatically recognizes last
estimated results left by csdid, csdid_estat and csdid_stats, to produce the corresponding plots.

Syntax

csdid_plot, [options]

Plot options

style(styleoption) Allows you to change the style of the plot. The options are rspike (default), rarea, rcap and rbar.

title(str) Sets title for the constructed graph

xtitle(str) Sets title for horizontal axis

ytitle(str) Sets title for vertical axis axis

name(str) Request storing a graph in memory under name

group(#) When using csdid_plot after csdid or after csdid_stats attgt, one can produce dynamic type
plots for each group/cohort. In that case, one needs to indicate which group(#) to plot.

pstyle[1|2](stype) This can be used to choose an overall style for the figure colors. Default is p1 for pstyle1 and p2 for pstyle2. pstyle2 is only used for event style plots.

color[1|2](colorstyle) This can be used to choose a color for areas of the figures. It superseeds pstyle if a color is defined, but complements it if using transparency or intencity. Default depends on the type of graph style, but is set at %40 for rspike.

lwidth[1|2](options) This can be used to select width of line in figure. It affects the tickness of the countours of Area type plots. Default depends on the type of graph style.

Other twoway graph options are allowed.

Remarks

The command csdid_plot is an easy-to-use command to plot different ATT aggregations, either across groups,
across time, or dynamic effects, (event plot). It has, however, limited flexibility

If you want to further modify this figure, I suggest using the community contributed command addplot by Benn Jan.
If you do, please cite his software. See references section.

csdid_rif: Module to create table results based on the var

csdid_rif is a command that can be used to create further tables based on RIF-variables in your dataset. For example, using csdid_stats event, one can save the event related RIF variables, as well as the simple Average ATT RIF. One can then use csdid_rif to create a table based on all these information.

Syntax

csdid_rif [varlist] [if in], [options]

Options

cluster(varname) Request estimating Clustered Standard errors. Default is Robust Standard errorsname

level(#) Indicates the CI level to be used. Default 95

wboot Request the estimation of Wildbootstrap SE with Uniform Confidence Intervals. Can be combined with Cluster option

reps(#) Requests # replications used for the Bootstrap. Default 999.

seed(#) Provides a Seed for replication purposes

Remarks

This command can also be used with any other output that provides the RIF functions. After the command is run, it will leave behind information in e()

Examples

ssc install frause
frause mpdta.dta, clear

Estimation of all ATTGT's using Doubly Robust IPW (DRIPW) estimation method. Saving RIF in disk

csdid lemp lpop , ivar(countyreal) time(year) gvar(first_treat) method(dripw) saverif(_rif_) replace

Estimation of all ATT aggregations

estat all

Estimation of all events between periods -2 to +2

estat event, window(-2 2)

Producing a simple Plot for last results. Two different styles

csdid_plot

estat event, window(-2 2)

csdid_plot, style(rarea)

Dynamic effects for group treated in 2006

csdid lemp lpop , ivar(countyreal) time(year) gvar(first_treat) method(dripw)

csdid_plot, group(2006)

Estimation of aggregations using RIF file. Using Asymptotic Standard errors and WBootstrap Standard errors

use _rif_, clear

Dynamic Effects with Asymptotic Standard errors

csdid_stats event

Dynamic Effects with Wbootstrap Std Err

csdid_stats event, wboot

Saving RIFs for all aggregations

csdid_stats event, save

csdid_stats calendar, save

csdid_stats group, save

Producing Tables Avg ATTs, using asymptotic Std Err

csdid_rif Pre_avg Post_avg CAverage GAverage

Producing Tables Avg ATTs, using Wboot Std Err and uniform Confidence Intervals

csdid_rif Pre_avg Post_avg CAverage GAverage, wboot

Authors

Fernando Rios-Avila

Levy Economics Institute of Bard College

Annandale-on-Hudson, NY

friosavi@levy.org

Pedro H. C. Sant'Anna

Vanderbilt University

Brantly Callaway

University of Georgia

References

Abadie, Alberto. 2005.
"Semiparametric Difference-in-Differences Estimators."
The Review of Economic Studies 72 (1): 1–19.

Callaway, Brantly and Sant'Anna, Pedro H. C. 2021.
"Difference-in-Differences with multiple time periods." , 225(2):200-230.
Journal of Econometrics.

Sant’Anna, Pedro H. C., and Jun Zhao. 2020.
"Doubly Robust Difference-in-Differences Estimators."
Journal of Econometrics 219 (1): 101–22.

Rios-Avila, Fernando,
Pedro H. C. Sant'Anna,
and Brantly Callaway, 2021.
“CSDID: Difference-in-Differences with Multiple periods.”

Jann, B. (2014). addplot: Stata module to add twoway plot objects to an existing twoway graph. Available from
http://ideas.repec.org/c/boc/bocode/s457917.html.

Aknowledgement

This command was built using the DID command from R as benchmark, originally written by Pedro Sant'Anna and Brantly Callaway.

Some of the additional tools and options are my attempt to provide things R version doesnt have yet.

Many thanks to Pedro for helping me understand the inner workings of the estimator.

Thanks also to Enrique, who helped with the display set up, plus other questions that pop up while working on this

Also see

Help: drdid, csdid, csdid postestimation, xtdidregress