Description Usage Arguments Details Value Estimated coefficients Effective sample a.k.a. Herfindahl condition Cohort Standard-errors Author(s) References Examples
View source: R/didImputation.R
DiD regression with imputation method
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
y0 |
Formula. model for Y(0). This is the full model without leads and lags used to predict the counterfactual outcome. |
data |
A data frame or data.table |
cohort |
Character. Time of treatment identifier. By default it expect |
nevertreated.value |
Any, default is |
unit |
Character, default is |
time |
Character, default is |
het |
Character, default is |
w |
Numerical vector or Variable name. Default is |
coef |
R Expression of leads and lags (eg |
OATT |
Logical, default is |
with.se |
Logical, default is |
tol |
Numeric, default is |
maxit |
Numeric, default is |
mutatedata |
Logical, default is |
verbose |
Numeric, default is |
effective.sample |
Numeric, default is |
See below for additional details on some arguments.
A didImputation object with the results of the imputation estimation.
data |
Data used for estimation. |
convergence_time |
User and CPU time for weights convergence. |
pvalue |
p-value for the positive horizon estimates. |
coeftable |
Table of regression coefficients. |
wald |
Wald statistic of the pre-trend regression. |
coefs |
Average treatment effects from the imputation procedure. |
niterations |
Number of iterations it took to compute the weights. |
pre_trends |
|
By default, the function will estimate all coefficients available. You can
customize this behavior with the coef
option. The option takes an R
expression of the form -{leads}:{lags}
. The default behavior is to estimate
all available coefficients such that coef = -Inf:Inf
.
For pre-trend coefficients, by default the function will set the greatest
leads as the reference group if -Inf
is set.
Borusyak, K., Jaravel, X., & Spiess, J. give a condition on weights such that consistency of estimators holds. This condition states that the Herfindahl index of weights must converge to zero. Another interpretation is that the inverse of the index is a measure of 'effective sample size'. Authors recommand an effective sample size of at least 30. If the effective sample size is lower, a warning will be thrown.
The cohort
argument is the date of treatment of the observation. By default
it expect Inf
for never treated individuals. You can override this behavior
by setting another value to nevertreated.value
.
The standard errors are computed using an alternating projection method. You
can tweek its meta-parameter by changing tol
and maxit
.
Antoine Mayerowitz
Maxime Gravoueille
Borusyak, K., Jaravel, X., & Spiess, J. (2021). Revisiting event study designs: Robust and efficient estimation. Working paper.
Stata implementation from the authors:
did_imputation (https://github.com/borusyak/did_imputation)
Another R implementation using sparse matrix inversion: didimputation (https://github.com/kylebutts/didimputation)
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 | #Load example data
data(did_simulated)
# Estimate the overall average treatment effect on treated and all available pre-trends
didImputation(y ~ 0 | i + t,
cohort = 'g',
OATT = TRUE,
data = did_simulated)
# Estimate the full dynamic model
didImputation(y ~ 0 | i + t,
cohort = 'g',
data = did_simulated)
# Estimate positive (lags) coefficients
didImputation(y ~ 0 | i + t,
cohort = 'g',
coef = 0:Inf,
data = did_simulated)
# Estimate first 3 post treatment coefficients
didImputation(y ~ 0 | i + t,
cohort = 'g',
coef = 0:2,
data = did_simulated)
# Return only point estimates
didImputation(y ~ 0 | i + t,
cohort = 'g',
with.se = FALSE,
data = did_simulated)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.