forked from evanjflack/bacondecomp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
72 lines (53 loc) · 2.59 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
output: github_document
---
[](https://cran.r-project.org/package=bacondecomp)

[](https://travis-ci.com/evanjflack/bacondecomp)
[](https://codecov.io/github/evanjflack/bacondecomp?branch=master)
[](https://mybinder.org/v2/gh/evanjflack/bacondecomp/master?filepath=index.ipynb)
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# bacondecomp
`bacondecomp` is a package with tools to perform the Goodman-Bacon decomposition for differences-in-differences with variation in treatment timing. The decomposition can be done with and without time-varying covariates.
## Installation
You can install `bacondecomp 0.1.2` from CRAN:
``` r
install.packages("bacondecomp")
```
You can install the development version of `bacondecomp` from GitHub:
``` r
library(devtools)
install_github("evanjflack/bacondecomp")
```
## Functions
* `bacon()`: calculates all 2x2 differences-in-differences estimates and weights for the Bacon-Goodman decomposition.
## Data
* `math_refom`: Aggregated data from Goodman (2019, JOLE)
* `castle`: Data from Cheng and Hoekstra (2013, JHR)
* `divorce:` Data from Stevenson and Wolfers (2006, QJE)
## Example
This is a basic example which shows you how to use the bacon() function to decompose the two-way fixed effects estimate of the effect of an education reform on future earnings following Goodman (2019, JOLE).
```{r example, fig.height = 4, fig.width = 6}
library(bacondecomp)
df_bacon <- bacon(incearn_ln ~ reform_math,
data = bacondecomp::math_reform,
id_var = "state",
time_var = "class")
library(ggplot2)
ggplot(df_bacon) +
aes(x = weight, y = estimate, shape = factor(type)) +
geom_point() +
geom_hline(yintercept = 0) +
labs(x = "Weight", y = "Estimate", shape = "Type")
```
## References
Goodman-Bacon, Andrew. 2018. "Difference-in-Differences with Variation in Treatment Timing." National Bureau of Economic Research Working Paper Series No. 25018. doi: 10.3386/w25018.
[Paper Link](https://cdn.vanderbilt.edu/vu-my/wp-content/uploads/sites/2318/2019/07/29170757/ddtiming_7_29_2019.pdf)