py-why / EconML

ALICE (Automated Learning and Intelligence for Causation and Economics) is a Microsoft Research project aimed at applying Artificial Intelligence concepts to economic decision making. One of its goals is to build a toolkit that combines state-of-the-art machine learning techniques with econometrics in order to bring automation to complex causal inference problems. To date, the ALICE Python SDK (econml) implements orthogonal machine learning algorithms such as the double machine learning work of Chernozhukov et al. This toolkit is designed to measure the causal effect of some treatment variable(s) t on an outcome variable y, controlling for a set of features x.
https://www.microsoft.com/en-us/research/project/alice/
Other
3.75k stars 711 forks source link

The question of the observed outcome input for DynamicDML #654

Open ZeyuJin opened 2 years ago

ZeyuJin commented 2 years ago

Hi,

I have a question related to the input of DynamicDML estimation. The comment suggests the input outcome is one-dimensional array with its length = *n_groups n_periods. n_periods** means the length of time series of each entity.

image

However, when I read the Algorithm 1 (which uses Neyman orthogonal g-estimation) in this reference paper [Lewis2021], the data input only uses the final observed outcome Ym. That is, Y = Ym for each sample. Actually all algorithms in this paper just assume single final outcome Ym (not the whole time series for each entity) as the data input.

I am confused why/how to specify a continuous time-step outcome Yi (i=1, ..., m) for the DynamicDML() input. Moreover, which specific algorithm is implemented in the class DynamicDML?

Thanks,

TimCosemans commented 1 month ago

This might be a late answer, but it could help someone struggling with the same question

It is not possible given the current version of the package (and the literature for that matter it seems), to estimate a model that estimates almost concurrent effects (of T_t on Y_t). Only effects on the final outcome (Y_m) of a treatment in t can be estimated.

As for which algorithm is implemented. All learners depend on the _OrthoLearner class in _ortho_learner.py. The algorithms proposed in Lewis & Syrgkanis (2022) consist of two steps: estimating the nuisances functions and the final model. The nuisances models are constructed for DynamicDML through the method _gen_ortho_learner_model_nuisance which creates an instance of class _DynamicModelNuisanceSelector (line 29 in panel/dml/dml.py). When these are trained use the method .train, for both X and W, only the concurrent features are passed (X_t and W_t for each time t, line 84 in panel/dml/_dml.py) through use of the period_filters[t] that are constructed using _get_groups_period_filter, not the entire histories. This makes the first part of this algorithm in line with algorithm 1 from the original paper (and not algorithm 3, page 19 of the paper states 'Thus the results we presented so far [i.e., algorithm 1] directly extend to the estimation of structural nested mean models [i.e., algorithm 3], with a linear parametrization of the blip functions, simply by using a different definition of the residual variables'. So that is where we can look for the differences.) As for the second part: Given that it is possible to include heterogeneity in the treatment effect, the final model is a linear regression in line with algorithm 4.

Hope this helps!