ddml_ate {ddml} | R Documentation |
Estimators of Average Treatment Effects.
Description
Estimators of the average treatment effect and the average treatment effect on the treated.
Usage
ddml_ate(
y,
D,
X,
learners,
learners_DX = learners,
sample_folds = 2,
ensemble_type = "nnls",
shortstack = FALSE,
cv_folds = 5,
custom_ensemble_weights = NULL,
custom_ensemble_weights_DX = custom_ensemble_weights,
subsamples_D0 = NULL,
subsamples_D1 = NULL,
cv_subsamples_list_D0 = NULL,
cv_subsamples_list_D1 = NULL,
trim = 0.01,
silent = FALSE
)
ddml_att(
y,
D,
X,
learners,
learners_DX = learners,
sample_folds = 2,
ensemble_type = "nnls",
shortstack = FALSE,
cv_folds = 5,
custom_ensemble_weights = NULL,
custom_ensemble_weights_DX = custom_ensemble_weights,
subsamples_D0 = NULL,
subsamples_D1 = NULL,
cv_subsamples_list_D0 = NULL,
cv_subsamples_list_D1 = NULL,
trim = 0.01,
silent = FALSE
)
Arguments
y |
The outcome variable. |
D |
The binary endogenous variable of interest. |
X |
A (sparse) matrix of control variables. |
learners |
May take one of two forms, depending on whether a single
learner or stacking with multiple learners is used for estimation of the
conditional expectation functions.
If a single learner is used,
If stacking with multiple learners is used,
Omission of the |
learners_DX |
Optional argument to allow for different estimators of
|
sample_folds |
Number of cross-fitting folds. |
ensemble_type |
Ensemble method to combine base learners into final estimate of the conditional expectation functions. Possible values are:
Multiple ensemble types may be passed as a vector of strings. |
shortstack |
Boolean to use short-stacking. |
cv_folds |
Number of folds used for cross-validation in ensemble construction. |
custom_ensemble_weights |
A numerical matrix with user-specified
ensemble weights. Each column corresponds to a custom ensemble
specification, each row corresponds to a base learner in |
custom_ensemble_weights_DX |
Optional argument to allow for different
custom ensemble weights for |
subsamples_D0 , subsamples_D1 |
List of vectors with sample indices for cross-fitting, corresponding to untreated and treated observations, respectively. |
cv_subsamples_list_D0 , cv_subsamples_list_D1 |
List of lists, each corresponding to a subsample containing vectors with subsample indices for cross-validation. Arguments are separated for untreated and treated observations, respectively. |
trim |
Number in (0, 1) for trimming the estimated propensity scores at
|
silent |
Boolean to silence estimation updates. |
Details
ddml_ate
and ddml_att
provide double/debiased machine
learning estimators for the average treatment effect and the average
treatment effect on the treated, respectively, in the interactive model
given by
Y = g_0(D, X) + U,
where (Y, D, X, U)
is a random vector such that
\operatorname{supp} D = \{0,1\}
, E[U\vert D, X] = 0
, and
\Pr(D=1\vert X) \in (0, 1)
with probability 1,
and g_0
is an unknown nuisance function.
In this model, the average treatment effect is defined as
\theta_0^{\textrm{ATE}} \equiv E[g_0(1, X) - g_0(0, X)]
.
and the average treatment effect on the treated is defined as
\theta_0^{\textrm{ATT}} \equiv E[g_0(1, X) - g_0(0, X)\vert D = 1]
.
Value
ddml_ate
and ddml_att
return an object of S3 class
ddml_ate
and ddml_att
, respectively. An object of class
ddml_ate
or ddml_att
is a list containing
the following components:
ate
/att
A vector with the average treatment effect / average treatment effect on the treated estimates.
weights
A list of matrices, providing the weight assigned to each base learner (in chronological order) by the ensemble procedure.
mspe
A list of matrices, providing the MSPE of each base learner (in chronological order) computed by the cross-validation step in the ensemble construction.
psi_a
,psi_b
Matrices needed for the computation of scores. Used in
summary.ddml_ate()
orsummary.ddml_att()
.oos_pred
List of matrices, providing the reduced form predicted values.
learners
,learners_DX
,subsamples_D0
,subsamples_D1
,cv_subsamples_list_D0
,cv_subsamples_list_D1
,ensemble_type
Pass-through of selected user-provided arguments. See above.
References
Ahrens A, Hansen C B, Schaffer M E, Wiemann T (2023). "ddml: Double/debiased machine learning in Stata." https://arxiv.org/abs/2301.09397
Chernozhukov V, Chetverikov D, Demirer M, Duflo E, Hansen C B, Newey W, Robins J (2018). "Double/debiased machine learning for treatment and structural parameters." The Econometrics Journal, 21(1), C1-C68.
Wolpert D H (1992). "Stacked generalization." Neural Networks, 5(2), 241-259.
See Also
summary.ddml_ate()
, summary.ddml_att()
Other ddml:
ddml_fpliv()
,
ddml_late()
,
ddml_pliv()
,
ddml_plm()
Examples
# Construct variables from the included Angrist & Evans (1998) data
y = AE98[, "worked"]
D = AE98[, "morekids"]
X = AE98[, c("age","agefst","black","hisp","othrace","educ")]
# Estimate the average treatment effect using a single base learner, ridge.
ate_fit <- ddml_ate(y, D, X,
learners = list(what = mdl_glmnet,
args = list(alpha = 0)),
sample_folds = 2,
silent = TRUE)
summary(ate_fit)
# Estimate the average treatment effect using short-stacking with base
# learners ols, lasso, and ridge. We can also use custom_ensemble_weights
# to estimate the ATE using every individual base learner.
weights_everylearner <- diag(1, 3)
colnames(weights_everylearner) <- c("mdl:ols", "mdl:lasso", "mdl:ridge")
ate_fit <- ddml_ate(y, D, X,
learners = list(list(fun = ols),
list(fun = mdl_glmnet),
list(fun = mdl_glmnet,
args = list(alpha = 0))),
ensemble_type = 'nnls',
custom_ensemble_weights = weights_everylearner,
shortstack = TRUE,
sample_folds = 2,
silent = TRUE)
summary(ate_fit)