Title: | Goodman-Bacon Decomposition |
---|---|
Description: | Decomposition for differences-in-differences with variation in treatment timing from Goodman-Bacon (2018) <doi:10.3386/w25018>. |
Authors: | Evan Flack [aut, cre], Edward Jee [aut], Kyle Butts [ctb] , Zachary Porreca [ctb] |
Maintainer: | Evan Flack <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.3 |
Built: | 2024-10-26 05:27:03 UTC |
Source: | https://github.com/evanjflack/bacondecomp |
bacon()
is a function that performs the Goodman-Bacon decomposition for
differences-in-differences with variation in treatment timing (with or
without time-varying covariates).
bacon(formula, data, id_var, time_var, quietly = TRUE)
bacon(formula, data, id_var, time_var, quietly = TRUE)
formula |
an object of class "formula". Must be of the form y ~ D + controls, where y is the outcome variable, D is the binary treatment indicator, and 'controls' can be any additional control variables. Do not include the fixed effects in the formula. |
data |
a data.frame containing the variables in the model. |
id_var |
character, the name of id variable for units. |
time_var |
character, the name of time variable. |
quietly |
logical. If TRUE then bacon() does not
print the summary of estimates/weights by type (e.g. Treated vs Untreated).
Default is TRUE. You can also use |
If control variables are included in the formula, then an object of class "list" with three elements:
Omega |
a number between 0 and 1, the weight of the within timing group coefficient |
beta_hat_w |
a number, the within timing group coefficient |
two_by_twos |
a data.frame with the covariate adjusted 2x2 estimates and weights |
If not control variables are included then only the two_by_twos data.frame is returned.
# Castle Doctrine (Uncontrolled) df_bacon <- bacon(l_homicide ~ post, data = bacondecomp::castle, id_var = "state", time_var = "year" ) # Castle Doctrine (Controlled) ret_bacon <- bacon(l_homicide ~ post + l_pop + l_income, data = bacondecomp::castle, id_var = "state", time_var = "year" )
# Castle Doctrine (Uncontrolled) df_bacon <- bacon(l_homicide ~ post, data = bacondecomp::castle, id_var = "state", time_var = "year" ) # Castle Doctrine (Controlled) ret_bacon <- bacon(l_homicide ~ post + l_pop + l_income, data = bacondecomp::castle, id_var = "state", time_var = "year" )
Uses the two-by-two output produced by
bacondecomp::bacon
to produce
average 2x2 estimate and total weight for the following three comparisons:
Earlier vs. Later (Good), Treated vs. Untreated (Good), and
Later vs. Earlier (Bad).
bacon_summary(two_by_twos, return_df = FALSE)
bacon_summary(two_by_twos, return_df = FALSE)
two_by_twos |
Data.frame produced by |
return_df |
Logical. If TRUE, then the summary data.frame is returned. Default is False. |
Data from Cheng and Hoekstra (2013, JHR)
castle
castle
A data.frame with 520 observations and 159 variables
The state (unit of analysis).
Calendar year (time).
Log of state/year homicide rate
Indicator whether castle reform has been implemented
Data from Stevenson and Wolfers (2006, QJE)
divorce
divorce
A data.frame with 3366 observations and 147 variables
A data set containing state/year level data on an educational reform and future income. This is an aggregated version of the data used by Goodman (2019, JOLE) to estimate the effect of compulsory high school math coursework on future earnings.
math_reform
math_reform
A data.frame with 520 observations and 5 variables
The state (unit of analysis).
The high school class (time).
Indicator for whether the reform was in place for the state/class.
The year the math reform was first implemented for the state. Set to NA if never implemented.
Natural log of future income.