twowayfeweights

Estimates the weights attached to the two-way fixed effects regressions studied in de Chaisemartin & D’Haultfoeuille (2020a), as well as summary measures of these regressions’ robustness to heterogeneous treatment effects.

Setup

Stata (SSC):

ssc install twowayfeweights, replace

R (CRAN):

install.packages("TwoWayFEWeights")

Vignettes

Syntax

Stata:

twowayfeweights Y G T D [D0], type(string)
  [summary_measures test_random_weights(varlist)
  controls(varlist) other_treatments(varlist) weight(varlist) path(string)]

R:

twowayfeweights(df, Y, G, T, D, D0 = NULL, type, summary_measures = NULL,
controls = c(), weights = NULL, other_treatments = c(), test_random_weights = c(), path = NULL)

Description

Options

FAQ

How can one interpret the summary measures of the regression’s robustness to heterogeneous treatment effects?

When the two-way fixed effects regression has only one treatment variable, the command reports two summary measures of the robustness of the treatment coefficient beta to treatment heterogeneity across groups and over time. The first one is defined in point (i) of Corollary 1 in de Chaisemartin & D’Haultfoeuille (2020a). It corresponds to the minimal value of the standard deviation of the treatment effect across the treated groups and time periods under which beta and the average treatment effect on the treated (ATT) could be of opposite signs. When that number is large, this means that beta and the ATT can only be of opposite signs if there is a lot of treatment effect heterogeneity across groups and time periods. When that number is low, this means that beta and the ATT can be of opposite signs even if there is not a lot of treatment effect heterogeneity across groups and time periods. The second summary measure is defined in point (ii) of Corollary 1 in de Chaisemartin & D’Haultfoeuille (2020a). It corresponds to the minimal value of the standard deviation of the treatment effect across the treated groups and time periods under which beta could be of a different sign than the treatment effect in all the treated group and time periods.

How can I tell if the first summary measure is high or low?

Assume that the first summary measure is equal to x. How can you tell if x is a low or a high amount of treatment effect heterogeneity? This is not an easy question to answer, but here is one possibility. Let us assume that the treatment effects of (g,t) cells are drawn from a uniform distribution. Then, to have that the mean of that distribution is 0 while its standard deviation is x, the treatment effects should be uniformly distributed on the [-sqrt(3)x,sqrt(3)x] interval. Then, you can ask yourself: is it reasonable to assume that some (g,t) cells have a treatment effect as large as sqrt(3)x, while other cells have a treatment effect as low as -sqrt(3)x? If the answer is negative, that is, you think that it is not reasonable to assume that the treatment effect will exceed the +/-sqrt(3)x bounds for some (g,t) cells, this means that the uniform distribution of treatment effects compatible with an ATT of 0 and a standard deviation of x seems implausible to you. Then, you can consider that the command’s first summary measure is high, and that it is unlikely that beta and the ATT are of a different sign. Conversely, if the answer is positive, that is, you believe that the treatment effect might exceed the bounds for some (g,t) cells, it may not be unlikely that beta and the ATT are of a different sign.

The previous sensitivity exercise assumes that treatment effects follow a uniform distribution. You may find it more reasonable to assume that they are, say, normally distributed. Then you can conduct the following, similar exercise. If the treatment effects of (g,t) cells are drawn from a normal distribution with mean 0 and standard deviation x normal distribution, 95% of them will fall within the [-1.96x,1.96x] interval, and 5% will fall outside of that interval. Then, you can ask yourself: is it reasonable to assume that 2.5% of (g,t) cells have a treatment effect larger than 1.96x, while 2.5% have a treatment effect lower than -1.96? If the answer is negative, that is, you are willing to assume that at most 2.5% of the treatment effects fall out of the [-1.96x,1.96x] interval at each side, this means that the normal distribution of treatment effects compatible with an ATT of 0 and a standard deviation of x seems implausible to you. Then, you can consider that the command’s first summary measure is high, and that it is unlikely that beta and the ATT are of a different sign.

How can I tell if the second summary measure is high or low?

Assume that the second summary measure is equal to x. To fix ideas, let us assume that beta>0. Let us assume that the treatment effects of (g,t) cells are drawn from a uniform distribution. Then, one could have that those effects are all negative, with a standard deviation equal to x, for instance if they are uniformly drawn from the [-2sqrt(3)x,0]. Then, you can ask yourself: is it reasonable to assume that some (g,t) cells have a treatment effect as low as -2sqrt(3)x? If the answer is negative, that is, you are not willing to assume that some (g,t) cells have a treatment effect lower than -2sqrt(3)x, this means that the uniform distribution of treatment effects compatible with sign reversal and a standard deviation of x seems implausible to you. Then, you can consider that the command’s second summary measure is high, and that sign reversal is unlikely. If the treatment effects of (g,t) cells are all negative, they cannot follow a normal distribution, so we do not discuss that possibility here.

Examples

The following example is based on data from F. Vella and M. Verbeek (1998), “Whose Wages Do Unions Raise? A Dynamic Model of Unionism and Wage Rate Determination for Young Men”. Results and further details about the estimation below can be found in Section V.C of de Chaisemartin & D’Haultfoeuille (2020a).

Stata

Run the following line to load the dataset:

use "https://raw.githubusercontent.com/chaisemartinPackages/twowayfeweights/main/wagepan_twfeweights.dta", clear

The next line estimates the weights from a TWFE regression of log wage (Y) on union status (D), individual worker (G) and year (T) fixed effects:

twowayfeweights lwage nr year union, type(feTR) test_random_weights(educ) summary_measures

The next line performs the same exercise using first differences of outcome and treatment:

twowayfeweights diff_lwage nr year diff_union union, type(fdTR) test_random_weights(educ) summary_measures

R

Run the following line to download the dataset in your local working directory and load it to your R environment:

library(TwoWayFEWeights)

## We need the haven package to read in the .dta file in this example
# install.packages("haven")

url = "https://raw.githubusercontent.com/chaisemartinPackages/twowayfeweights/main/wagepan_twfeweights.dta"
wagepan =  haven::read_dta(url)

The next line estimates the weights from a TWFE regression of log wage (Y) on union status (D), individual worker (G) and year (T) fixed effects:

est = twowayfeweights(
  wagepan,                        # dataset
  "lwage", "nr", "year", "union", # Required Y, G, T, and D args
  type                = "feTR",   # start of optional args...
  summary_measures    = TRUE,
  test_random_weights = "educ"
)

The next line performs the same exercise using first differences of outcome and treatment:

est2 = twowayfeweights(
  wagepan,
  "diff_lwage", "nr", "year", "diff_union", # use differenced versions of Y and D
  type                = "fdTR",             # changed
  D0                  = "union",            # added (req'd arg for fdTR type)
  summary_measures    = TRUE,
  test_random_weights = "educ"
)

Warning

Please note that the number of negative weights could be different from Section V.C. of de Chaisemartin and D’Haultfoeuille (2020a) due to rounding errors that affected older versions of the commands.

References

Authors

The development of this package was funded by the European Union (ERC, REALLYCREDIBLE,GA N°101043899).

Contact

chaisemartin.packages@gmail.com