forked from susanathey/MCPanel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
executable file
·61 lines (44 loc) · 2.36 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
---
output: github_document
---
# `MCPanel`: Imputation Estimators for Causal Effects in Panel Data
Fork of [Athey et al's MCPanel](https://github.com/susanathey/MCPanel/) package with additional imputation methods for causal inference in panel data. Supported imputation methods:
+ matching (via `filling`)
+ kernel matching (kernel PCA via `kernlab` followed by `filling`)
+ dynamic factor model (`dfms`)
+ sparse dynamic factor model (`sparseDFM`)
+ matrix completion
+ two-way FE / DID
+ synthetic control
+ horizontal ridge regression
+ vertical ridge regression
These methods can all be implemented using the `imputation_ATT` function. Inference can be performed using the bootstrap / jack-knife (when number of treated units > 1) using the `boot` library [implementation in progress].
## Example
using Abadie, Diamond, Hainmueller (2010) California Prop 99 data.
```{r}
# install.packages("apoorvalal/MCPanel")
pacman::p_load(MCPanel, synthdid) # for data
data(california_prop99)
```
`imputation_ATT` takes a panel data set, identifiers for unit, time, treatment, and outcome, and a vector of method names (must be supported by `imputationY`: includes `"did", "dfm", "sdfm", "knn", "kknn", "nuclear", "hardimpute", "svdimpute", "optspace", "mc", "sc", "env", "enh"`).
```{r}
# call all with defaults
est = imputation_ATT(
california_prop99,
"State", "Year", "treated", "PacksPerCapita",
# method specific arguments are passed as lists
# check docs for imputationY for details
dfm_args = list(r = 4, p = 1),
sdfm_args = list(r = 4, q = 2)
)
# The print method returns ATT estimates.
print(est)
```
The plot method makes an event study figure. The legend contains ATT estimates, and its width may need to be customized.
```{r, fig.width = 11, fig.height = 6}
plot(est, prec = 2, twd = 5.5)
```
Factor models perform poorly here, as does difference in differences. Most other methods have good pre-trends and broadly agree.
#### References
Susan Athey, Mohsen Bayati, Nikolay Doudchenko, Guido Imbens, and Khashayar Khosravi. <b>Matrix Completion Methods for Causal Panel Data Models</b> [<a href="http://arxiv.org/abs/1710.10251">link</a>]
Licheng Liu, Ye Wang, and Yiqing Xu. "A Practical Guide to Counterfactual Estimators for Causal Inference with Time‐Series Cross‐Sectional Data." American Journal of Political Science (2022). [link](https://arxiv.org/abs/2107.00856)