matheusfacure / python-causality-handbook

Causal Inference for the Brave and True. A light-hearted yet rigorous approach to learning about impact estimation and causality.
https://matheusfacure.github.io/python-causality-handbook/landing-page.html
MIT License
2.74k stars 475 forks source link

Ch. 22 Non-scientific DML #235

Open jeffCollinsLM opened 2 years ago

jeffCollinsLM commented 2 years ago

I have a comment as well as a question. At the end of Ch. 22 you have the counterfactual method for populating the full demand curve for each data point. I am a researcher in the insurance industry and we have used this counterfactual method for several years at my company.

The comment is that I think the custom cross-fold prediction function is unnecessary at this step. The prediction of the treatment model is the same for every one of the counterfactual prices, so to create the treatment residual T-twiddle it is sufficient to create counterfactual T-twiddle values directly. What we do is prior to fitting the stage 2 ML model we define T-twiddle multiplicatively as a ratio of prices and we train the stage 2 model on that ratio. So when it comes to the counterfactual step we can just join in some counterfactual T-twiddles such as 0.9, 0.95, 1.00, 1.05, 1.10...those are created by hand...with the 1.00 corresponding to the price being equal to the expected price (treatment.) Could you let me know if you see a problem with that approach?

I'm also very curious whether you have since found any examples of this counterfactual approach in the literature. Thanks!

Padarn commented 2 years ago

Sorry I only have a comment on the last part here.

Isn't this approach the same as https://www.math.mcgill.ca/dstephens/PSMMA/Articles/HIrano-Imbens-2004.pdf And also implemented in https://github.com/cran/causaldrf/blob/master/R/hi_est.R

Maybe I'm missing something?

matheusfacure commented 2 years ago

Honestly, when I wrote this, all of it was completely from my head. Causal inf. is evolving rapidly, so it's no surprise that recent material has emerged on the topic. I should probably move this to an entirely new chapter on counterfactual predictions. I also found this video about the topic on YouTube

https://www.youtube.com/watch?v=Ubt_sH2qRMg&t=575s

Padarn commented 2 years ago

The Hirano Imbens paper is not very new... but I will admit I hadn't connected the dots until I read your material. I'm sure new chapters would be popular :-)

yanzhangcun commented 9 months ago

In this chapter, i want to run the codes in your book, but there no nb21 packages. could you tell me how to install this package in my computer?

BlackTornadofrom1999 commented 3 months ago

In this chapter, i want to run the codes in your book, but there no nb21 packages. could you tell me how to install this package in my computer?

Me too, where can i find this package?

BlackTornadofrom1999 commented 3 months ago

In this chapter, i want to run the codes in your book, but there no nb21 packages. could you tell me how to install this package in my computer?

https://github.com/RobertMelika/ML-S-T-DR-CATE-Resp-Care/blob/main/nb21.py