*! version 2.0 May_4_2024

Title

jwdid -- ETWFE-DID estimator

Syntax

jwdid
[varlist]
[if] [in]
[weight]
[, options]

Basic Specification options
ivar(varname) Declares the Panel ID variable. If not declared, the data is assumed to be Repeated crossection.

tvar(varname) Declares the time variable

time(varname) Same as tvar()

gvar(varname) Provides the cohort variable

Treatment-control Specification options
trtvar(varname) If Gvar is not available, you can provide the post-treatment variable. By default, the panel data identifier is used to create the equivalent to Gvar

trgvar(varname) If data is repeated crossection (RC), trtvar() can be combined with trtgvar() to identify the cohort variable. trtgvar should identify a pseudo panels in the data, where each pseudo panel are observations that were (or could have) been treated at the same point in time

Basic DID Specification options
never By default, jwdid uses all never and not-yet treated observations as controls. The option never request to use only never-treated as the control group. With this option, for each group/cohort, the period g-1 is excluded from the specification.

group Request using Group fixed effects instead of Panel ID fixed effects. In linear models, with balanaced panel, estimates are numerically identical. However, it may reduce the computational burden with nonlinear models. This is the default whenver method() is called for except for ppmlhdfe.

corr When using group with unbalanced panel data, estimates are no longer identical to those that use the panel identifier fixed effect. The option corr applies a correction for this, following a Mundlak approach

cluster(varname) This option is used to request standard errors to be clustered at cluster() level. When using panel data, the default is using ivar() for clustering standard errors. When using RC data, Standard errors are estimated based on the Method default. For reghdfe, one should use vce(robust) to obtain robust standard errors.

method(method_name) Request other methods for the estimation of ATT's. For example poisson or logit. Default is linear regression model, which is estimated using reghdfe.

other_options It is also possible to request other method/specific options. For example, for reghdfe robust standard errors can be requested using vce(robust).

Advanced DID Specification options
hettype(hetspec) This option allows to request different types of treatment effect heterogeneity. The default is to use full timecohort heterogeneity. Other options include time, cohort, event and twfe. The last one reduces to the traditional TWFE estimator

xasis Unless this option is requested, all variables in varlist are demeaned and interacted with the corresponding level of treatment heterogeneity. Declaring xasis requests using covariates without transformation.

exovar(varlist) Variables declared using this option are added to the model specification without interactions

xtvar(varlist) Variables declared are only interacted with the time variable

xgvar(varlist) Variables declared are only interacted with the group/cohort variable.

fevar(varlist) This option is used to add additional fixed effects to the model, that different from cohort, panel or time. Only valid when using default method (reghdfe) or if using ppmlhdfe.

anticipation(#1) This is used to declare period different from g-1 as the baseline. #1 can only take integer positve values, default is 1

pweights are allowed; see weight.

Description

jwdid is a program that implements the Extended TWFE estimator proposed by Wooldridge(2021,2023) for a generalized DID design that addresses the problems related to the standard TWFE. The program also incorporates additional options that allow for a more flexible model specification. This includes the guidelines for the estimation of Gravity-trade models as proposed by Nagengast and Yotov (2024) and Nagengast et al (2024).

In principle, this estimator suggests that to avoid some of the negative aspects of the traditional TWFE-DID estimator, one should simply use a fully interacted set of dummies allowing for treatment effect heterogeneity by cohort and timing. By using such interaction, one avoids using already treated units as controls causing the so-called negative weights problems.

Specifically, instead of estimating a model as follows:

y_it = gamma * D_it + a_i + b_t + e_t

where D_it indicates if unit i is treated at time t. One should estimate a model like the following:

y_it = sum(gamma_gt * G_i * T) + a_i + b_t + e_t

where G_i * T corresponds to all possible interactions of the cohort unit i belongs to (G_i) and the period we aim to estimate that effect at (T), using as reference group all units that have not been treated yet.

In the simplest case, gamma_gt represents the ATT for cohort G at time t. When the option never is used, the specification also includes the Group period interactions including all those periods before treatment occured. In the case without covariates, the estimates are numerically identical to those identified using Callaway and Sant'Anna (2021)-regression outcome method, or using Sun and Abraham (2021) approach.

Similar to xthdidregres and hdidregress, it is possible to estimate the DID model by declaring a treatment variable trtvar() instead of the group variable gvar(). Similarly, to reduce the complexity of the estimation, it is possible to impose some restrictions on the treatment effect heterogeneity using hettype().

In addition to impossing constrains to the treatment effect heterogeneity, it is also possible to add covariates that allows for covariate heterogeneity, as well as restricting the heterogneity only across time, across cohorts or no heterogeneity at all. Any variable that is included in the varlist is interacted with the corresponding level of treatment heterogeneity. The default option is to add sub-group demeaned variables to the model, but it is possible to request using the original variables using the option xasis. Both approaches produces the same aggregate average treatment effects, but the interpretation of the model coefficients is changes.

One can also request adding variable that are interacted with the time variable only xtvar(), cohort variable only xgvar(), or not interacted at all exovar(). Similarly, additional fixed effects can be added to the model using the option fevar().

One should also be aware that jwdid will create as many interactions as cohorts and periods are there in the data, times all possible controls, unless heterogeneity is restricted and covariate heterogeneity is restricted using the above options.

This could provide an extreamly large number of estimated coefficients, which could make some models difficult to estimate.

Other estimation methods can be used by declaring the option method(). The default method is reghdfe, which is a linear regression model with fixed effects. Other methods include poisson, logit, or ppmlhdfe, which is the leading approaach for the estimation of gravity-trade models.

Except when ppmlhdfe is used, whever method() is declared, the program will assume group/cohort fixed effects only, instead of individual fixed effects. This is to avoid the incidental parameter problem.

Remarks

The code of this program is based on some of the advances by Prof. Wooldridge on the estimation of DID models. It has important advantages over other methods:

1. It is based on regression analysis, and most people understand regression, compared to the other alternatives.

2. It is flexible for other methods. Namely, you should be easily be able to apply it for binary or count models, or even for the estimation of gravity-trade models, as we show in Nagengast et al (2024).

This program was coded independently from Jeff Wooldridge, but is based on some of his early simulation codes he shared with the community. Some further advances were made following the official implentation of xthdidregress and hdidregress. Most advanced were developed for the joint work with Arne Nagengast and Yoto Yotov, for the estimation of DID type models in gravity trade settings.

To estimate aggregates, see jwdid_postestimation

Examples

Setup

ssc install frause

frause mpdta.dta, clear

Simple DID using not-treated as controls

jwdid lemp, ivar(countyreal) tvar(year) gvar(first_treat)

Simple DID using never treated as controls

jwdid lemp, ivar(countyreal) tvar(year) gvar(first_treat) never

Simple DID using not-treated as controls, based on group (rather than individual) fixed effects

jwdid lemp, ivar(countyreal) tvar(year) gvar(first_treat) group

DID using not-treated as controls, based on group (rather than individual) fixed effects, and one time invariant control.

jwdid lemp lpop, ivar(countyreal) tvar(year) gvar(first_treat) group

DID using not-treated as controls, based on group (rather than individual) fixed effects, and one time invariant control. Using poisson regression estimator.

gen emp = exp(lemp)

jwdid emp lpop, ivar(countyreal) tvar(year) gvar(first_treat) method(poisson)

DID using never treated as controls, using different treatment effects heterogeneity restrictions.

jwdid lemp, ivar(countyreal) tvar(year) gvar(first_treat) never hettype(time)

jwdid lemp, ivar(countyreal) tvar(year) gvar(first_treat) never hettype(cohort)

jwdid lemp, ivar(countyreal) tvar(year) gvar(first_treat) never hettype(event)

jwdid lemp, ivar(countyreal) tvar(year) gvar(first_treat) never hettype(twfe)

Authors

Fernando Rios-Avila

Levy Economics Institute of Bard College

Annandale-on-Hudson, NY

friosavi@levy.org

Arne J. Nagengast

Deutsche Bundesbank

arne.nagengast@bundesbank.de

Yoto V. Yotov

School of Economics,Drexel University

yotov@drexel.edu

References

Nagengast, Arne J., Fernando Rios-Avila and Yoto V. Yotov. 2024. The European Single Market and Intra-EU Trade: An Assessment with Heterogeneity-Robust Difference-in-Differences Methods.
School of Economics Working Paper Series 2024-5, LeBow College of Business, Drexel University. https://ideas.repec.org/p/ris/drxlwp/2024_005.html. Paper.

Nagengast, Arne J. and Yoto V. Yotov. 2024. Staggered Difference-in-Differences in Gravity Settings: Revisiting the Effects of Trade Agreements. American Economic Journal: Applied Economics (forthcoming).

Wooldridge, Jeffrey. 2021.
Two-Way Fixed Effects, the Two-Way Mundlak Regression, and Differences-in-Differences
estimators. Working paper.

Wooldridge, Jeffrey. 2023.
Simple Approaches to Nonlinear Difference-in-Differences with Panel Data. The Econometrics Journal, Volume 26, Issue 3, September 2023, Pages C31–C66.

Aknowledgement

This command started as an isolated project before becoming a dad! 2 years later and Im almost ready to get a much better version of it.

Also see

Help: drdid, csdid, jwdid_postestimation, xtdidregress, xthdidregress, hdidregress