Repository navigation
ENH: Treatment effect rebased - #8034
Conversation
|
Hello @josef-pkt! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2022-06-22 01:17:48 UTC |
|
examples are in statsmodels/examples/ex_treatment_effects.py example file runs without problems and no assert fails |
|
from what I remember:
|
|
This pull request introduces 1 alert when merging 7ba1d67 into b0b0e5f - view on LGTM.com new alerts:
|
|
I need to figure out which is which in my code and example eg. matching Stata's my version here does not include a moment condition for AT directly, parameters are the POMs |
|
It looks like vce(robust) is HC0 in Stata teffects ra I have hardcoded hc1, but if I reestimate with HC0, then I get a good match with Stata's bse ra from the example file in this PR AFAIR, GMM defaults to HC0, but in "ra" we use 2 OLS models, and WLS in weighted IPW cases |
|
Still bugs in RegAdjustment method based on example file the second is the explicit computation in the example file and corresponds to Stata. The other methods match Stata, based on brief checking. Aside: |
|
plan for basic design:
target in first round, params_table for ATE, POM0 and POM1, with linear outcome model example: where mom_olsex is used because OLS, WLS don't have score_obs |
|
I'm not sure what references I used for the different methods in RegAdjustment class. The computation look more like formulas from the original articles or from survey articles. Lunceford, J. K., and M. Davidian. 2004. Stratification and weighting via the propensity update update2 Tan, Zhiqiang. 2007. “Comment: Understanding OR, PS and DR.” Statistical Science 22 (4): 560–68. https://doi.org/10.1214/07-STS227A. |
|
Note, GLM score_factor and consequently score_obs include iweights (freq_weights * var_weights) For GMM outcome moment conditions I need numerical derivative of GLM.score_obs w.r.t weights, i.e. I cannot include fixed weights. If I want to delegate to and reuse models, then I will need several models, i.e. it will not be low memory, |
|
another decision: rearranged observations (by group) or original order of observations The regression methods use the outcome model split by treatment group. AFAICS, in the current RegAdjustment methods, the inconsistent ordering is irrelevant because we only use averages over observations when combining different terms, e.g. predicted mean for the exog in original order. However for cov_params/bse with GMM, we need consistent moment conditions. I have not looked at what Stata has in We need at least to predict POMs conditional on treatment level (and other exog), i.e. predict of outcome models (with two sets of params if treated or not, and corresponding cov_params). another possibility: Related: if we use different models by groups, then we need separate |
|
optimization problems update: my current result versus Stata for IPWRA: |
|
This pull request introduces 1 alert when merging 2e6c2fa into 2891644 - view on LGTM.com new alerts:
|
2e6c2fa to
59c4c67
Compare
|
This pull request introduces 1 alert when merging 59c4c67 into 053dcc1 - view on LGTM.com new alerts:
|
|
style check only fails in statsmodels/examples/ex_treatment_effects.py which will be deleted before merge
|
|
This pull request introduces 1 alert when merging 48727ad into 053dcc1 - view on LGTM.com new alerts:
|
|
The core computation should be finished now no cleanup or refactoring yet, separate GMM class for each method (as I wrote the prototype version) |
|
still no ATT a bit surprising: |
|
I think I will return just a simple results/Holder instance instead of GMMresults, and attach the gmm results instance as attribute. basic summary table/dataframe should be just ATT, POM0 and POM1 with inference, basically return from t_test GMMResults does not have mle_retvals and related. We need some overlap diagnostic, but that is based only on the selection/treatment model for propensity score. |
|
ATT: AIPW, including wnls version, does not have ipwra requires changing weights in outcome regression, and not just moments for effects, target statistics. (ATT, POMT) ra: ATT, POMT is just computing averages for subsample, i.e. treated group ipw: ATT, POMT effects are computed as sample averages using probability being in subgroup, i.e. probability of being treated for ATT. Looks like we need to do the same computation as for ATE, POM0, but with adjusted weights. It doesn't look like we can reuse moment conditions nor just add the ATT, POMT versions to the existing moments. In an article by Wooldridge, he allows for separate group membership probabilities, where group membership is not necessarily related to treatment status. Here we have only 3 cases, ATE, ATT and effect on nontreated ATNT (?). Stata doesn't have an stratification: let user do this: i.e. run two TreatmentEffect estimates groupby gender. |
|
API: prob keyword, e.g providing a prob only makes sense if we don't use inference, i.e. return_results=False. The only usecase I can think of would be a very limited bootstrap with parametric bootstrap for the selection model, with unchanged outcome and outcome model. (plain IPW is the only one that does not have an outcome model/exog) We could compute numdiff of ATE w.r.t prob. we still have a backdoor to change prob because the preliminary computation of ATE and POMs use an attribute -> remove prob keyword (*) brief google search does not find much on outlier influence for treatment effect Canavire-Bacarreza, Gustavo, Luis Castro Peñarrieta, and Darwin Ugarte Ontiveros. 2021. “Outliers in Semi-Parametric Estimation of Treatment Effects.” Econometrics 9 (2): 19. https://doi.org/10.3390/econometrics9020019. Harada, Kazuharu, and Hironori Fujisawa. 2021. “Outlier-Resistant Estimators for Average Treatment Effect in Causal Inference.” ArXiv:2106.13946 [Stat], June. http://arxiv.org/abs/2106.13946. |
|
I'm returning now a subclass or ContrastResults example from unit test case |
|
based on coverage report:
used for outcome model: mom_ols_te (in IPW), mom_olsex (all others, not for ipw) function ate_ipw is used as preliminary estimator in TreatmentEffects.ipw
other: that can be removed now effects are now always |
|
I'm adding ATT
-> I will add new subclass also for ipw |
8defbb2 to
70b8aa0
Compare
|
rebased to get new PR checks My pytest is broken since the rebase :( |
|
very annoying: checking out an old PR and rebasing deletes the update I still don't like pip, it's annoying, using setup.py directly was much much easier and faster |
70b8aa0 to
0535620
Compare
|
not added to any api.py yet merging, docstring need rendering checks |
rebased version of #2455 (2015)
rebased without merge conflicts, but I didn't look at it yet