R/ipw_did_panel.R
ipw_did_panel.Rd
ipw_did_panel
is used to compute inverse probability weighted (IPW) estimators for the ATT
in difference-in-differences (DiD) setups with panel data. IPW weights are not normalized to sum up to one,
that is, the estimator is of the Horwitz-Thompson type.
ipw_did_panel(
y1,
y0,
D,
covariates,
i.weights = NULL,
boot = FALSE,
boot.type = "weighted",
nboot = NULL,
inffunc = FALSE
)
An \(n\) x \(1\) vector of outcomes from the post-treatment period.
An \(n\) x \(1\) vector of outcomes from the pre-treatment period.
An \(n\) x \(1\) vector of Group indicators (=1 if observation is treated in the post-treatment, =0 otherwise).
An \(n\) x \(k\) matrix of covariates to be used in the propensity score estimation. Please add a vector of constants if you want to include an intercept in the models. If covariates = NULL, this leads to an unconditional DiD estimator.
An \(n\) x \(1\) vector of weights to be used. If NULL, then every observation has the same weights. The weights are normalized and therefore enforced to have mean 1 across all observations.
Logical argument to whether bootstrap should be used for inference. Default is FALSE.
Type of bootstrap to be performed (not relevant if boot = FALSE
). Options are "weighted" and "multiplier".
If boot = TRUE
, default is "weighted".
Number of bootstrap repetitions (not relevant if boot = FALSE
). Default is 999.
Logical argument to whether influence function should be returned. Default is FALSE.
A list containing the following components:
The IPW DiD point estimate.
The IPW DiD standard error
Estimate of the upper bound of a 95% CI for the ATT
Estimate of the lower bound of a 95% CI for the ATT
All Bootstrap draws of the ATT, in case bootstrap was used to conduct inference. Default is NULL
Estimate of the influence function. Default is NULL
The matched call.
Some arguments used (explicitly or not) in the call (panel = TRUE, normalized = FALSE, boot, boot.type, nboot, type="ipw")
Abadie, Alberto (2005), "Semiparametric Difference-in-Differences Estimators", Review of Economic Studies, vol. 72(1), p. 1-19, doi:10.1111/0034-6527.00321
Sant'Anna, Pedro H. C. and Zhao, Jun. (2020), "Doubly Robust Difference-in-Differences Estimators." Journal of Econometrics, Vol. 219 (1), pp. 101-122, doi:10.1016/j.jeconom.2020.06.003
# Form the Lalonde sample with CPS comparison group
eval_lalonde_cps <- subset(nsw, nsw$treated == 0 | nsw$sample == 2)
# Further reduce sample to speed example
set.seed(123)
unit_random <- sample(1:nrow(eval_lalonde_cps), 5000)
eval_lalonde_cps <- eval_lalonde_cps[unit_random,]
# Select some covariates
covX = as.matrix(cbind(1, eval_lalonde_cps$age, eval_lalonde_cps$educ,
eval_lalonde_cps$black, eval_lalonde_cps$married,
eval_lalonde_cps$nodegree, eval_lalonde_cps$hisp,
eval_lalonde_cps$re74))
# Implement (unnormalized) IPW DiD with panel data
ipw_did_panel(y1 = eval_lalonde_cps$re78, y0 = eval_lalonde_cps$re75,
D = eval_lalonde_cps$experimental,
covariates = covX)
#> Call:
#> ipw_did_panel(y1 = eval_lalonde_cps$re78, y0 = eval_lalonde_cps$re75,
#> D = eval_lalonde_cps$experimental, covariates = covX)
#> ------------------------------------------------------------------
#> IPW DID estimator for the ATT:
#>
#> ATT Std. Error t value Pr(>|t|) [95% Conf. Interval]
#> -724.1929 692.1639 -1.0463 0.2954 -2080.8342 632.4484
#> ------------------------------------------------------------------
#> Estimator based on panel data.
#> Horvitz-Thompson-type IPW estimator.
#> Propensity score est. method: maximum likelihood.
#> Analytical standard error.
#> ------------------------------------------------------------------
#> See Sant'Anna and Zhao (2020) for details.