# synthdid
**Repository Path**: simon1239/synthdid
## Basic Information
- **Project Name**: synthdid
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-02-22
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# synthdid: Synthetic Difference in Differences Estimation
This package implements the synthetic difference in difference estimator (SDID) for the
average treatment effect in panel data, as proposed in Arkhangelsky et al (2019).
We consider a setting in which we observe a matrix `Y = L + tau W + noise` where W
is a matrix of indicators for treatment. All treated units must begin treatment simultaneously,
so W indicates a treated block, i.e. `W[i,j] = 1` for `i > N_0, j > T_0` and is zero otherwise.
This applies, in particular, to the case of a single treated unit.
To install this package in R, run the following commands:
```R
library(devtools)
install_github("synth-inference/synthdid")
```
Example usage:
```R
library(synthdid)
library(mvtnorm)
n_0 <- 100
n_1 <- 10
T_0 <- 120
T_1 <- 20
n <- n_0 + n_1
T <- T_0 + T_1
tau <- 1
sigma <- .5
rank <- 2
rho <- 0.7
var <- outer(1:T, 1:T, FUN=function(x, y) rho^(abs(x-y)))
W <- (1:n > n_0) %*% t(1:T > T_0)
U <- matrix(rpois(rank * n, sqrt(1:n) / sqrt(n)), n, rank)
V <- matrix(rpois(rank * T, sqrt(1:T) / sqrt(T)), T, rank)
mu <- U %*% t(V)
error <- rmvnorm(n, sigma = var, method = "chol")
Y <- mu + tau * W + sigma * error
tau.hat = synthdid_estimate(Y,n_0,T_0)
print(paste("true tau:", tau))
print(paste0("point estimate: ", round(tau.hat, 2)))
print(paste0("95% CI for tau: (", round(tau.hat - 1.96 * attr(tau.hat, 'se'), 2), ", ", round(tau.hat + 1.96 * attr(tau.hat, 'se'), 2), ")"))
```
#### References
Dmitry Arkhangelsky, Susan Athey, David A. Hirshberg, Guido W. Imbens, and Stefan Wager.
Synthetic Difference in Differences
2019.
[arxiv]