├── .github
├── CODEOWNERS
├── chapter-xxx.md
└── pull_request_template.md
├── .gitignore
├── LICENSE
├── README.md
└── causal-inference-for-the-brave-and-true
├── 01-Introduction-To-Causality.ipynb
├── 02-Randomised-Experiments.ipynb
├── 03-Stats-Review-The-Most-Dangerous-Equation.ipynb
├── 04-Graphical-Causal-Models.ipynb
├── 05-The-Unreasonable-Effectiveness-of-Linear-Regression.ipynb
├── 06-Grouped-and-Dummy-Regression.ipynb
├── 07-Beyond-Confounders.ipynb
├── 08-Instrumental-Variables.ipynb
├── 09-Non-Compliance-and-LATE.ipynb
├── 10-Matching.ipynb
├── 11-Propensity-Score.ipynb
├── 12-Doubly-Robust-Estimation.ipynb
├── 13-Difference-in-Differences.ipynb
├── 14-Panel-Data-and-Fixed-Effects.ipynb
├── 15-Synthetic-Control.ipynb
├── 16-Regression-Discontinuity-Design.ipynb
├── 17-Predictive-Models-101.ipynb
├── 18-Heterogeneous-Treatment-Effects-and-Personalization.ipynb
├── 19-Evaluating Causal Models.ipynb
├── 20-Plug-and-Play-Estimators.ipynb
├── 21-Meta-Learners.ipynb
├── 22-Debiased-Orthogonal-Machine-Learning.ipynb
├── 23-Challenges-with-Effect-Heterogeneity-and-Nonlinearity.ipynb
├── 24-The-Difference-in-Differences-Saga.ipynb
├── _config.yml
├── _toc.yml
├── data
├── ak91.csv
├── app_engagement_push.csv
├── billboard_impact.csv
├── collections_email.csv
├── customer_features.csv
├── customer_transactions.csv
├── drinking.csv
├── enem_scores.csv
├── hospital_treatment.csv
├── ice_cream_sales.csv
├── ice_cream_sales_rnd.csv
├── img
│ ├── beyond-conf
│ │ ├── cop-ex1.png
│ │ ├── cop-ex2.png
│ │ ├── cop.png
│ │ ├── selection.png
│ │ ├── shocked.png
│ │ └── y-pred.png
│ ├── brave-and-true.png
│ ├── causal-graph
│ │ ├── both_crap.png
│ │ ├── selection_bias.png
│ │ └── three_bias.png
│ ├── causal-model
│ │ ├── customers.png
│ │ ├── economists.png
│ │ ├── elast-partition.png
│ │ ├── elast-split.png
│ │ ├── elasticity.png
│ │ ├── linear-fix.png
│ │ ├── y-partition.png
│ │ └── y-split.png
│ ├── curse-of-dimensionality.jpg
│ ├── debias-ps
│ │ ├── again.png
│ │ ├── fear-no-man.png
│ │ └── ps-experiment.png
│ ├── debiased-ml
│ │ ├── avengers.png
│ │ ├── cf-pred.png
│ │ ├── cross-prediction.png
│ │ ├── diagram.png
│ │ ├── drown-ols.png
│ │ ├── linear-aprox.png
│ │ ├── ml-problem.png
│ │ ├── more-metrics.png
│ │ ├── non-linear.png
│ │ └── non-sci.png
│ ├── did-saga
│ │ ├── awful.jpeg
│ │ ├── death.png
│ │ ├── promise.png
│ │ └── twfeworking.png
│ ├── diff-in-diff
│ │ ├── cant-read.png
│ │ ├── non-parallel.png
│ │ └── secrets.png
│ ├── doubly-robust
│ │ └── double.png
│ ├── dummy
│ │ ├── heterosk.png
│ │ └── you_little_shit.png
│ ├── evaluate-causal-models
│ │ ├── ate_bins.png
│ │ ├── cumm_elast.png
│ │ ├── cumm_gain.png
│ │ ├── sneak.png
│ │ └── uncivilised.png
│ ├── fixed-effects
│ │ ├── control-unit.png
│ │ ├── demeaned.png
│ │ ├── fe-graph.png
│ │ └── time-travel.png
│ ├── graph-flow.png
│ ├── hte-binary-outcome
│ │ ├── logistic.png
│ │ └── slide-susan-athey.png
│ ├── industry-ml
│ │ ├── cascade-1.png
│ │ ├── cascade-2.png
│ │ ├── cashflow-1.png
│ │ ├── cross-validation.png
│ │ ├── ml-flow.png
│ │ ├── ml-meme.png
│ │ ├── model-fit.png
│ │ ├── overfitting.jpg
│ │ ├── profit.png
│ │ ├── test.png
│ │ └── translation.png
│ ├── intro
│ │ ├── anatomy1.png
│ │ ├── anatomy2.png
│ │ ├── anatomy3.png
│ │ ├── anatomy4.png
│ │ ├── potential_outcomes.png
│ │ └── tougher-up-cupcake1.jpg
│ ├── iv
│ │ ├── good-iv.png
│ │ ├── incomplete-files.png
│ │ ├── qob.png
│ │ └── weak-iv.png
│ ├── late
│ │ ├── always_takers.png
│ │ ├── defiers.png
│ │ └── double_index.png
│ ├── linear-regression
│ │ ├── confused_cat.png
│ │ └── you_vs.png
│ ├── matching
│ │ ├── explain.png
│ │ ├── its-a-match.png
│ │ └── ubiquitous-ols.png
│ ├── meta-learners
│ │ ├── learned-new-move.png
│ │ ├── not-great-not-terrible.jpeg
│ │ ├── s-learner.png
│ │ ├── second-stage-x.png
│ │ ├── t-learner-problem.png
│ │ ├── t-learner.png
│ │ ├── t-vs-x-learner.png
│ │ ├── x-learner.png
│ │ └── zero-bias-s-learner.png
│ ├── orthogonal
│ │ ├── athlas.png
│ │ ├── kfold-cv.png
│ │ └── nazare-confusa.jpg
│ ├── plug-and-play-estimators
│ │ ├── genious.jpeg
│ │ ├── infeasible.png
│ │ ├── linear-case.png
│ │ ├── non-linear-case.png
│ │ └── second-estimator.png
│ ├── poetry.png
│ ├── ps
│ │ ├── balance.png
│ │ ├── bootstrap.png
│ │ ├── iptw.png
│ │ └── ml-trap.png
│ ├── rct
│ │ ├── indep.png
│ │ ├── lurking_bias.png
│ │ └── science_dream.png
│ ├── rdd
│ │ ├── ols.png
│ │ ├── rdd.png
│ │ ├── rdd_fuzzy.png
│ │ └── smooth.png
│ ├── sc-conformal-inf
│ │ ├── aug-data.png
│ │ └── block-perm.png
│ ├── stats-review
│ │ ├── ci_xkcd.png
│ │ ├── normal_dist.jpeg
│ │ └── p_value.png
│ ├── synth-control
│ │ ├── allways.png
│ │ ├── extrapolation.png
│ │ ├── out-of-sample.png
│ │ ├── regr_space.png
│ │ ├── regr_space_x.png
│ │ ├── regr_time.png
│ │ └── synth_img.png
│ └── when-prediction-fails
│ │ ├── flat-curves.png
│ │ ├── graph-1.png
│ │ ├── graph-2.png
│ │ ├── graph-3.png
│ │ ├── horse-meme.png
│ │ ├── ml-in-5.png
│ │ ├── model-opt.png
│ │ ├── opt-deriv.png
│ │ ├── pandas-magic.png
│ │ ├── partitions.png
│ │ ├── personalise.png
│ │ ├── slice-1.png
│ │ ├── slice-2.png
│ │ └── waiting-time.png
├── invest_email.csv
├── invest_email_biased.csv
├── invest_email_rnd.csv
├── learning_mindset.csv
├── medicine_impact_recovery.csv
├── online_classroom.csv
├── sheepskin.csv
├── smoking.csv
├── trainees.csv
├── wage.csv
└── when-prediction-fails
│ ├── graph-1.png
│ ├── graph-2.png
│ ├── graph-3.png
│ ├── horse-meme.png
│ ├── ml-in-5.png
│ ├── model-opt.png
│ ├── opt-deriv.png
│ ├── pandas-magic.png
│ ├── partitions.png
│ ├── personalise.png
│ ├── slice-1.png
│ ├── slice-2.png
│ └── waiting-time.png
└── landing-page.md
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # This is a comment.
2 | # Each line is a file pattern followed by one or more owners.
3 | # These owners will be the default owners for everything in the repo.
4 | * @jsshin2022
--------------------------------------------------------------------------------
/.github/chapter-xxx.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Chapter XXX
3 | about: Propose a correction / 오타 수정 / 번역 수정
4 | title: ''
5 | labels: ''
6 | assignees: jsshin
7 |
8 | ---
9 | There is an issue on chapter XXX, in the following paragraph
10 | [paragraph here]
11 |
12 | It should be
13 | [suggestion here]
14 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ## Status
2 | WIP/Review Required/Ready for Merge
3 |
4 |
5 | ## Description
6 | - Chapter 11 오타 수정
7 | - Chapter별 cell tag 추가
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # =============================================================================
2 | # Python
3 | # https://github.com/github/gitignore/blob/master/Python.gitignore
4 | # =============================================================================
5 |
6 | # Byte-compiled / optimized / DLL files
7 | __pycache__/
8 | *.py[cod]
9 | *$py.class
10 |
11 | # C extensions
12 | *.so
13 |
14 | # Distribution / packaging
15 | .Python
16 | build/
17 | develop-eggs/
18 | dist/
19 | downloads/
20 | eggs/
21 | .eggs/
22 | lib/
23 | lib64/
24 | parts/
25 | sdist/
26 | var/
27 | wheels/
28 | pip-wheel-metadata/
29 | share/python-wheels/
30 | *.egg-info/
31 | .installed.cfg
32 | *.egg
33 | MANIFEST
34 |
35 | # PyInstaller
36 | # Usually these files are written by a python script from a template
37 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
38 | *.manifest
39 | *.spec
40 |
41 | # Installer logs
42 | pip-log.txt
43 | pip-delete-this-directory.txt
44 |
45 | # Unit test / coverage reports
46 | htmlcov/
47 | .tox/
48 | .nox/
49 | .coverage
50 | .coverage.*
51 | .cache
52 | nosetests.xml
53 | coverage.xml
54 | *.cover
55 | *.py,cover
56 | .hypothesis/
57 | .pytest_cache/
58 |
59 | # Translations
60 | *.mo
61 | *.pot
62 |
63 | # Django stuff:
64 | *.log
65 | local_settings.py
66 | db.sqlite3
67 | db.sqlite3-journal
68 |
69 | # Flask stuff:
70 | instance/
71 | .webassets-cache
72 |
73 | # Scrapy stuff:
74 | .scrapy
75 |
76 | # Sphinx documentation
77 | docs/_build/
78 |
79 | # PyBuilder
80 | target/
81 |
82 | # Jupyter Notebook
83 | .ipynb_checkpoints
84 |
85 | # IPython
86 | profile_default/
87 | ipython_config.py
88 |
89 | # pyenv
90 | .python-version
91 |
92 | # pipenv
93 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
95 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
96 | # install all needed dependencies.
97 | #Pipfile.lock
98 |
99 | # celery beat schedule file
100 | celerybeat-schedule
101 |
102 | # SageMath parsed files
103 | *.sage.py
104 |
105 | # Environments
106 | .env
107 | .venv
108 | env/
109 | venv/
110 | ENV/
111 | env.bak/
112 | venv.bak/
113 |
114 | # Spyder project settings
115 | .spyderproject
116 | .spyproject
117 |
118 | # Rope project settings
119 | .ropeproject
120 |
121 | # mkdocs documentation
122 | /site
123 |
124 | # mypy
125 | .mypy_cache/
126 | .dmypy.json
127 | dmypy.json
128 |
129 | # Pyre type checker
130 | .pyre/
131 |
132 |
133 | # =============================================================================
134 | # JetBrains IDEs
135 | # https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
136 | # =============================================================================
137 |
138 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
139 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
140 |
141 | # User-specific stuff
142 | .idea/**/workspace.xml
143 | .idea/**/tasks.xml
144 | .idea/**/usage.statistics.xml
145 | .idea/**/dictionaries
146 | .idea/**/shelf
147 |
148 | # Generated files
149 | .idea/**/contentModel.xml
150 |
151 | # Sensitive or high-churn files
152 | .idea/**/dataSources/
153 | .idea/**/dataSources.ids
154 | .idea/**/dataSources.local.xml
155 | .idea/**/sqlDataSources.xml
156 | .idea/**/dynamic.xml
157 | .idea/**/uiDesigner.xml
158 | .idea/**/dbnavigator.xml
159 |
160 | # Gradle
161 | .idea/**/gradle.xml
162 | .idea/**/libraries
163 |
164 | # Gradle and Maven with auto-import
165 | # When using Gradle or Maven with auto-import, you should exclude module files,
166 | # since they will be recreated, and may cause churn. Uncomment if using
167 | # auto-import.
168 | # .idea/modules.xml
169 | # .idea/*.iml
170 | # .idea/modules
171 | # *.iml
172 | # *.ipr
173 |
174 | # CMake
175 | cmake-build-*/
176 |
177 | # Mongo Explorer plugin
178 | .idea/**/mongoSettings.xml
179 |
180 | # File-based project format
181 | *.iws
182 |
183 | # IntelliJ
184 | out/
185 |
186 | # VS Code
187 | .vscode/
188 |
189 | # mpeltonen/sbt-idea plugin
190 | .idea_modules/
191 |
192 | # JIRA plugin
193 | atlassian-ide-plugin.xml
194 |
195 | # Cursive Clojure plugin
196 | .idea/replstate.xml
197 |
198 | # Crashlytics plugin (for Android Studio and IntelliJ)
199 | com_crashlytics_export_strings.xml
200 | crashlytics.properties
201 | crashlytics-build.properties
202 | fabric.properties
203 |
204 | # Editor-based Rest Client
205 | .idea/httpRequests
206 |
207 | # Android studio 3.1+ serialized cache file
208 | .idea/caches/build_file_checksums.ser
209 |
210 |
211 | # =============================================================================
212 | # macOS
213 | # https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
214 | # =============================================================================
215 |
216 | # General
217 | .DS_Store
218 | .AppleDouble
219 | .LSOverride
220 |
221 | # Icon must end with two \r
222 | Icon
223 |
224 |
225 | # Thumbnails
226 | ._*
227 |
228 | # Files that might appear in the root of a volume
229 | .DocumentRevisions-V100
230 | .fseventsd
231 | .Spotlight-V100
232 | .TemporaryItems
233 | .Trashes
234 | .VolumeIcon.icns
235 | .com.apple.timemachine.donotpresent
236 |
237 | # Directories potentially created on remote AFP share
238 | .AppleDB
239 | .AppleDesktop
240 | Network Trash Folder
241 | Temporary Items
242 | .apdisk
243 |
244 |
245 | # =============================================================================
246 | # Custom
247 | # =============================================================================
248 |
249 | .idea/*
250 | causal-inference-for-the-brave-and-true/_build/*
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 가짜연구소 Causal Inference Lab
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Python으로 하는 인과추론 : 개념부터 실습까지
2 |
3 | ## Causal Inference for The Brave and True 책 번역
4 | [](https://zenodo.org/badge/latestdoi/255903310)
5 | [](https://hits.seeyoufarm.com)
6 |
7 | 안녕하세요. [가짜연구소](https://pseudo-lab.com/) Causal Inference 팀입니다.
8 |
9 | 이 책은 Matheus Facure (Nubank Data Scientist)의 [Causal Inference for The Brave and True](https://matheusfacure.github.io/python-causality-handbook/landing-page.html)을 한국어로 번역한 자료입니다. 이 책은 인과추론에 대한 기본 개념과 Python 실습, 나아가 최신 사례까지 모두 다루고 있습니다. 인과추론에 대한 이론과 실습자료가 많지 않은 상황에서 이 책은 인과추론 처음 접하거나 인과추론에 대한 이해를 바탕으로 사례를 접하고 싶은 분 모두를 만족시킬 수 있는 책이라고 생각합니다. 한국에서 인과추론을 공부하시는 분들께 많은 도움이 되었으면 좋겠습니다. 해당 한국어 번역 자료는 [Jupyter Book](https://causalinferencelab.github.io/Causal-Inference-with-Python/landing-page.html)으로도 배포되어 있으니 많은 관심 부탁드립니다.
10 |
11 | 가짜연구소 Causal Inference 팀은 전문 번역가가 아닌, 데이터분석가/과학자/연구자로 구성 되어 있습니다. 따라서, 한국어 번역 과정에서 이상하거나 어색한 부분이 발생할 수 있어요. 해당 부분에 대한 여러분의 피드백을 부탁드립니다. 또한, 한국어 표현이 익숙하지 않은 부분에 대해서는 영어로 그대로 표현했습니다. 해당 부분 이해부탁드려요.
12 |
13 |
14 | 마지막으로, 이 책의 한국어 번역에 동의해 주신 Matheus Facure에게 감사의 말씀을 전합니다.
15 | 그리고, 번역과 실습자료를 만들기 위해 같이 고생해준 Causal Inference 팀 멤버들에게도 진심으로 감사드립니다!
16 |
17 |
18 |
19 |
20 |
21 |
22 | 이 책은 Joshua Angrist, Alberto Abadie, Christopher Walters, Miguel Hernan 및 Jamie Robins 등을 포함한 많은 연구자들의 계량 경제학 수업과 바탕으로 하고 있으며, 대부분의 아이디어는 전미경제학회(American Economic Association)의 수업에서 가져왔습니다. 이 책을 작성하기 위해 참고한 자료와 서적은 아래와 같습니다.
23 |
24 | * [Cross-Section Econometrics](https://www.aeaweb.org/conference/cont-ed/2017-webcasts)
25 | * [Mastering Mostly Harmless Econometrics](https://www.aeaweb.org/conference/cont-ed/2020-webcasts)
26 | * [Mostly Harmless Econometrics](https://www.mostlyharmlesseconometrics.com/)
27 | * [Mastering 'Metrics](https://www.masteringmetrics.com/)
28 | * [Causal Inference Book](https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/)
29 |
30 |
31 |
32 | ## 자료 이슈 및 관련 질문
33 | 번역 자료에 대한 이슈가 있다면, 해당 Github 저장소의 [이슈 페이지](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/issues)를 방문해주세요. 또한, 관련 질문은 빌더인 [신진수](https://github.com/jsshin2022)에게 문의 부탁드립니다.
34 |
35 |
36 |
37 | ## 한국어 번역 일정
38 |
39 | Causal Inference for The Brave and True에 대한 한국어 번역은 아래와 같은 일정에 따라 진행되었습니다.
40 | Part2의 경우, 저자의 부탁에 따라 추후 진행될 예정입니다.
41 |
42 | | 순서 | 완료여부 | Chapter | 완료일 | 작성자 |
43 | | ------ | -- |----------- |------|------|
44 | | 1 | ☑️ | [1. Introduction To Causality](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/01-Introduction-To-Causality.ipynb) | 2022-08-20 | [신진수](https://github.com/jsshin2022)
45 | | 2 | ☑️ | [2. Randomised Experiments](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/02-Randomised-Experiments.ipynb) | 2022-12-04 | [최은희](https://github.com/EunHuiChoi) |
46 | | 3 | ☑️ | [3. Stats Review: The Most Dangerous Equation](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/03-Stats-Review-The-Most-Dangerous-Equation.ipynb) | 2022-11-10 | [김준영](https://github.com/CptAswadu) |
47 | | 4 | ☑️ | [4. Graphical Causal Models](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/04-Graphical-Causal-Models.ipynb) | 2022-11-23 | [김소희](https://github.com/soheekim911) |
48 | | 5 | ☑️ | [5. The Unreasonable Effectiveness of Linear Regression](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/05-The-Unreasonable-Effectiveness-of-Linear-Regression.ipynb) | 2022-11-23 | [남궁민상](https://github.com/wholmesian) |
49 | | 6 | ☑️ | [6. Grouped and Dummy Regression](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/06-Grouped-and-Dummy-Regression.ipynb) | 2022-11-05 | [정호재](https://github.com/wjdghwo) |
50 | | 7 | ☑️ | [7. Beyond Confounders](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/07-Beyond-Confounders.ipynb) | 2022-11-26 | [김상돈](https://github.com/SANGDONKIM) |
51 | | 8 | ☑️ | [8. Instrumental Variables](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/08-Instrumental-variables.ipynb) | 2022-12-04 | [최은희](https://github.com/EunHuiChoi) |
52 | | 9 | ☑️ | [9. Non Compliance and LATE](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/09-Non-Compliance-and-LATE.ipynb) | 2022-11-19 | [김성수](https://github.com/fenzhantw) |
53 | | 10 | ☑️ | [10. Matching](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/10-Matching.ipynb) | 2022-11-04 | [김상돈](https://github.com/SANGDONKIM)
54 | | 11 | ☑️ | [11. Propensity Score](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/11-Propensity%20Score.ipynb) | 2022-11-11 | [김성수](https://github.com/fenzhantw) |
55 | | 12 | ☑️ | [12. Doubly Robust Estimation](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/12-Doubly-Robust-Estimation.ipynb) | 2022-10-28 | [홍성철](https://github.com/chulhongsung) |
56 | | 13 | ☑️ | [13. Difference-in-Differences](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/13-Difference-in-Differences.ipynb) | 2022-08-27 | [신진수](https://github.com/jsshin2022) |
57 | | 14 | ☑️ | [14. Panel Data and Fixed Effects](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/14-Panel-Data-and-Fixed-Effects.ipynb) | 2022-11-26 | [신진수](https://github.com/jsshin2022) |
58 | | 15 | ☑️ | [15. Synthetic Control](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/15-Synthetic-Control.ipynb) | 2022-09-03 | [정호재](https://github.com/wjdghwo)
59 | | 16 | ☑️ | [16. Regression Discontinuity Design](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/16-Regression-Discontinuity-Design.ipynb) | 2022-11-22 | [남궁민상](https://github.com/wholmesian) |
60 | | 21 | ☑️ | [21. Meta Learners](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/blob/main/causal-inference-for-the-brave-and-true/21-Meta-Learners.ipynb) | 2023-12-31 | [박병수](https://github.com/Hinterhalter) |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/02-Randomised-Experiments.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "cf97ccf2",
7 | "metadata": {},
8 | "source": [
9 | "# 02 - Randomised Experiments\n",
10 | "## The Golden Standard\n",
11 | "\n",
12 | "이전 세션에서, 우리는 연관성(association)이 어떻게 인과성(causation)과 다른지 살펴보았습니다. 우리는 또한 연관성(association)을 인과성(causation)으로 만드는 데 필요한 것들이 무엇인지도 살펴보았습니다.\n",
13 | "\n",
14 | "$E[Y|T=1] - E[Y|T=0] = \\underbrace{E[Y_1 - Y_0|T=1]}_{ATT} + \\underbrace{\\{ E[Y_0|T=1] - E[Y_0|T=0] \\}}_{BIAS}$\n",
15 | "\n",
16 | "\n",
17 | "다시 떠올려보자면, 연관성은 편향이 존재하지 않을때 비로소 인과성이 될 수 있습니다. $E[Y_0|T=0]=E[Y_0|T=1]$를 만족할 때 편향은 없을 것이라고 말할 수 있습니다. 즉, 타겟군과 대조군이 처치를 받은 것을 제외하고 타겟군과 대조군이 동등하거나 유사하다면 연과성은 인과관계가 될 것입니다. 혹은 더 전문적인 표현을 사용하자면, 처치를 받지 않은 군의 결과가 처치를 받은 군의 반사실적 결과와 동등할때 연관성이 인과관계가 되는 것이 성립됩니다. 이러한 반사실적 결과가 처치를 받지 않은 타겟군의 결과와 같다는 것을 기억해야할 것입니다.\n",
18 | "\n",
19 | "제가 생각하기에 우리는 수식을 통해 어떻게 연관성이 인과성이 되는지 비교적 잘 설명한 것 같습니다. 그러나 이는 이론에만 국한됩니다. 이제 우리는 이러한 편향을 없앨 수 있는 첫번째 툴, **무작위 실험(Randomised Experiments)** 에 대해서 살펴볼 것입니다. 무작위 실험은 타겟군(Treatment Group)과 대조군(Control group)에 개개인을 랜덤으로 분배하는 방식입니다. 처치를 받는 타겟군의 비율이 꼭 50%일 필요는 없습니다. 여러분의 표본(samples)의 10%만이 처치를 받는 실험을 진행할 수도 있습니다.\n",
20 | "\n",
21 | "랜덤 분배는 잠재적 결과(potential outcomes)를 처치(treatment)로부터 독립적으로 만듦으로써 편향을 제거합니다.\n",
22 | "\n",
23 | "$(Y_0, Y_1) \\perp\\!\\!\\!\\perp T$\n",
24 | "\n",
25 | "물론 처음에는 혼란스러울 수 있습니다. (저도 혼란스러웠습니다.) 하지만 걱정하지 마세요. 제가 더 친절히 설명하겠습니다! 도출된 결과(Outcome Y)가 처치로부터 독립적이라면, 이는 처치가 전혀 효과가 없었다는 것을 암시하는 것이 아닐까요? 맞습니다. 하지만 제가 결과에 대해 말하고 있는 것이 아님을 명심하세요. 대신, 저는 **잠재적** 결과(**potential** outcomes) 에 대해서 말할거에요. 잠재적 결과(potential outcomes)란, 결과가 만약 처치($Y_1$)와 대조($Y_0$)의 영향 아래 있었다면 어땠을까를 가정하는 것입니다. 무작위 시도에서는, **처치가 결과의 원인**이 된다고 생각하기 때문에 결과가 처치로부터 **독립적**이길 바라지 않습니다.\n",
26 | "\n",
27 | "\n",
28 | "\n",
29 | "잠재적 결과(potential outcomes)가 처치로부터 무관하다는 것은 기대대로라면 처치군(Treatment group; 처치를 받은 그룹)이나 대조군(Control group; 처치를 받지 않은 그룹)에서도 같은 결과가 나와야한다는 것을 의미합니다. 더 간단히 말해보면, 처치군(타겟군)과 대조군은 비교가 가능하다는 것입니다! 또한 이 말은 처치군이 실험자에게 처치 이전의 결과에 대해 그 어떤 정보도 주지 않는다는 것을 의미하기도 합니다. 결과적으로 $(Y_0, Y_1) \\bot T$ 수식은 '가한 처치(treatment)'가 처치군의 결과와 대조군의 결과 사이에서 발생한 유일한 차이라는 것을 의미합니다. 이것을 확인하기 위해 독립성이 아래와 같은 내용을 내포하고 있다는 것을 알아야 합니다.\n",
30 | "\n",
31 | "$E[Y_0|T=0] = E[Y_0|T=1] = E[Y0]$\n",
32 | "\n",
33 | "이미 우리가 확인한대로 이렇게도 만들어볼 수 있겠죠.\n",
34 | "\n",
35 | "$E[Y|T = 1] - E[Y|T = 0] = E[Y_1 - Y_0] = ATE$\n",
36 | "\n",
37 | "따라서, 랜덤 분배(Randomization)는 처치 효과(Treatment effect)라고 하는 타겟군과 대조군 간의 작은 차이를 만들 수 있는 것입니다.\n",
38 | "\n",
39 | "## In a School Far, Far Away\n",
40 | "2020년에 코로나 바이러스의 전세계적인 유행으로 인해 기업들은 사회적 거리두기에 적응해야만 했습니다. 배달 서비스가 확산되었고, 대기업들은 원격 근무 전략으로 전환했습니다. 학교도 다르지 않았습니다. 많은 학교들이 온라인 학습 환경 구축을 시작했습니다.\n",
41 | "\n",
42 | "위기가 시작된지 4개월이 지난 지금, 많은 사람들은 이러한 변화들이 지속될 수 있을지 의문을 가집니다. 온라인 학습 환경이 차별화된 장점을 가지고 있다는 것엔 의심의 여지가 없습니다. 우선 부동산과 교통의 측면에서 절약을 할 수 있다는 점에서 저렴합니다. 또한 정해진 선생들로부터만 교육을 제공받는 것이 아닌 조금 더 디지털적으로, 즉, 전세계의 세계적인 수준의 학습 콘텐츠를 활용할 수 있다는 것입니다. 이러한 장점들에도 불구하고 우리는 온라인 수업이 학생들의 학습 퍼포먼스에 부정적인 영향을 미치는지 긍정적인 영향을 미치는지 여전히 궁금해합니다.\n",
43 | "\n",
44 | "이에 대한 한 가지 답으로, 주로 온라인 수업을 진행하는 수업의 학생들과 오프라인 수업 장소에서 강의를 듣는 학생들을 비교하는 것입니다. 우리가 알고 있는 대로 이것은 최고의 접근 방식은 아니긴 합니다. 온라인 수업이 실제 오프라인 수업이었어도 평균적인 학생들보다 더 잘하는 훈련된 학생들만을 끌어들일 수도 있기 때문입니다. 이러한 경우에선 처치를 받은 집단이 학업적으로 처치를 받지 않은 그룹보다 좋은 결과를 보여주는 긍정 편항(positive bias)을 발견할 수 있습니다: $E[Y_0|T=1] > E[Y_0|T=0]$\n",
45 | "\n",
46 | "또한 반대 상황을 생각해보자면, 온라인 수업이 더 저렴하여 공부 외에 다른 일들을 해야하는 부유하지 않은 학생들로 구성되어 있을 수도 있습니다. 이런 경우에는 이 학생들이 오프라인을 수업을 듣는다할지라도 실제 오프라인 수업을 듣는 학생들보다 좋은 학업 퍼포먼스를 보여주지 못할 수도 있습니다. 이런 상황이 발생할 경우, 우린 처치를 받은 그룹이 처치를 받지 않은 그룹보다 학업적 성과가 나쁘다는 다른 측면의 편향: 부정 편향(negative bias)을 가질 수 있습니다: $E[Y_0|T=1] < E[Y_0|T=0]$\n",
47 | "\n",
48 | "그러므로 우리가 이런 간단한 비교를 하더라도, 이런 비교들은 설득력이 없을 것이라는 것입니다. 어떤 방식으로 하든지 우리는 우리가 발견하고자 하는 인과 효과( causal effect)를 가리고 있는 여러 편향(bias)들이 없다고 절대 확신할 수 없습니다.\n",
49 | "\n",
50 | "\n",
51 | "\n",
52 | "이를 해결하기 위해, 우리는 처치군과 처치를 진행하지 않은 군을 비교가능하게 만들어야 합니다. $E[Y_0|T=1] = E[Y_0|T=0]$ 학생들을 온라인 수업과 현 방식의 수업(대면 수업)에 무작위로 배정하는 것이 하나의 방법이 될 수 있겠네요. 만약 우리가 그렇게 한다면, 처치를 받은 그룹과 받지 않은 그룹은 그들이 받은 처치를 제외하고는 평균적으로 같아야 할 것입니다.\n",
53 | "\n",
54 | "놀랍게도 한 경제학자들은 우리를 위해 이 작업을 미리 해두었습니다. 그들은 첫번째 그룹의 학생들은 대면 강의를, 두번째 학생들은 온라인 수업을, 세번째 그룹의 학생들에게는 혼합형 수업을 듣도록 랜덤 배정을 진행하였습니다. 또한 학기 말에 진행한 시험에 대한 데이터를 모았죠.\n",
55 | "\n",
56 | "데이터는 아래와 같습니다."
57 | ]
58 | },
59 | {
60 | "cell_type": "code",
61 | "execution_count": 81,
62 | "id": "7fe03e84",
63 | "metadata": {
64 | "tags": [
65 | "hide-input"
66 | ]
67 | },
68 | "outputs": [
69 | {
70 | "name": "stdout",
71 | "output_type": "stream",
72 | "text": [
73 | "(323, 10)\n"
74 | ]
75 | },
76 | {
77 | "data": {
78 | "text/html": [
79 | "
\n",
80 | "\n",
93 | "
\n",
94 | " \n",
95 | " \n",
96 | " \n",
97 | " gender \n",
98 | " asian \n",
99 | " black \n",
100 | " hawaiian \n",
101 | " hispanic \n",
102 | " unknown \n",
103 | " white \n",
104 | " format_ol \n",
105 | " format_blended \n",
106 | " falsexam \n",
107 | " \n",
108 | " \n",
109 | " \n",
110 | " \n",
111 | " 0 \n",
112 | " 0 \n",
113 | " 0.0 \n",
114 | " 0.0 \n",
115 | " 0.0 \n",
116 | " 0.0 \n",
117 | " 0.0 \n",
118 | " 1.0 \n",
119 | " 0 \n",
120 | " 0.0 \n",
121 | " 63.29997 \n",
122 | " \n",
123 | " \n",
124 | " 1 \n",
125 | " 1 \n",
126 | " 0.0 \n",
127 | " 0.0 \n",
128 | " 0.0 \n",
129 | " 0.0 \n",
130 | " 0.0 \n",
131 | " 1.0 \n",
132 | " 0 \n",
133 | " 0.0 \n",
134 | " 79.96000 \n",
135 | " \n",
136 | " \n",
137 | " 2 \n",
138 | " 1 \n",
139 | " 0.0 \n",
140 | " 0.0 \n",
141 | " 0.0 \n",
142 | " 0.0 \n",
143 | " 0.0 \n",
144 | " 1.0 \n",
145 | " 0 \n",
146 | " 1.0 \n",
147 | " 83.37000 \n",
148 | " \n",
149 | " \n",
150 | " 3 \n",
151 | " 1 \n",
152 | " 0.0 \n",
153 | " 0.0 \n",
154 | " 0.0 \n",
155 | " 0.0 \n",
156 | " 0.0 \n",
157 | " 1.0 \n",
158 | " 0 \n",
159 | " 1.0 \n",
160 | " 90.01994 \n",
161 | " \n",
162 | " \n",
163 | " 4 \n",
164 | " 1 \n",
165 | " 0.0 \n",
166 | " 0.0 \n",
167 | " 0.0 \n",
168 | " 0.0 \n",
169 | " 0.0 \n",
170 | " 1.0 \n",
171 | " 1 \n",
172 | " 0.0 \n",
173 | " 83.30000 \n",
174 | " \n",
175 | " \n",
176 | "
\n",
177 | "
"
178 | ],
179 | "text/plain": [
180 | " gender asian black hawaiian hispanic unknown white format_ol \\\n",
181 | "0 0 0.0 0.0 0.0 0.0 0.0 1.0 0 \n",
182 | "1 1 0.0 0.0 0.0 0.0 0.0 1.0 0 \n",
183 | "2 1 0.0 0.0 0.0 0.0 0.0 1.0 0 \n",
184 | "3 1 0.0 0.0 0.0 0.0 0.0 1.0 0 \n",
185 | "4 1 0.0 0.0 0.0 0.0 0.0 1.0 1 \n",
186 | "\n",
187 | " format_blended falsexam \n",
188 | "0 0.0 63.29997 \n",
189 | "1 0.0 79.96000 \n",
190 | "2 1.0 83.37000 \n",
191 | "3 1.0 90.01994 \n",
192 | "4 0.0 83.30000 "
193 | ]
194 | },
195 | "execution_count": 81,
196 | "metadata": {},
197 | "output_type": "execute_result"
198 | }
199 | ],
200 | "source": [
201 | "import pandas as pd\n",
202 | "import numpy as np\n",
203 | "\n",
204 | "data = pd.read_csv(\"./online_classroom.csv\")\n",
205 | "print(data.shape)\n",
206 | "data.head()"
207 | ]
208 | },
209 | {
210 | "cell_type": "markdown",
211 | "id": "591514db",
212 | "metadata": {},
213 | "source": [
214 | "우리는 323개의 샘플들을 볼 수 있습니다. 큰 데이터는 아니지만, 우리가 무언갈 해볼 순 있겠습니다. 인과 효과를 추정하기 우해 우리는 각 처치 그룹의 평균 점수를 내볼 수 있겠네요."
215 | ]
216 | },
217 | {
218 | "cell_type": "code",
219 | "execution_count": 82,
220 | "id": "6521e8eb",
221 | "metadata": {
222 | "tags": [
223 | "hide-input"
224 | ]
225 | },
226 | "outputs": [
227 | {
228 | "data": {
229 | "text/html": [
230 | "\n",
231 | "\n",
244 | "
\n",
245 | " \n",
246 | " \n",
247 | " \n",
248 | " gender \n",
249 | " asian \n",
250 | " black \n",
251 | " hawaiian \n",
252 | " hispanic \n",
253 | " unknown \n",
254 | " white \n",
255 | " format_ol \n",
256 | " format_blended \n",
257 | " falsexam \n",
258 | " \n",
259 | " \n",
260 | " class_format \n",
261 | " \n",
262 | " \n",
263 | " \n",
264 | " \n",
265 | " \n",
266 | " \n",
267 | " \n",
268 | " \n",
269 | " \n",
270 | " \n",
271 | " \n",
272 | " \n",
273 | " \n",
274 | " \n",
275 | " blended \n",
276 | " 0.550459 \n",
277 | " 0.217949 \n",
278 | " 0.102564 \n",
279 | " 0.025641 \n",
280 | " 0.012821 \n",
281 | " 0.012821 \n",
282 | " 0.628205 \n",
283 | " 0.0 \n",
284 | " 1.0 \n",
285 | " 77.093731 \n",
286 | " \n",
287 | " \n",
288 | " face_to_face \n",
289 | " 0.633333 \n",
290 | " 0.202020 \n",
291 | " 0.070707 \n",
292 | " 0.000000 \n",
293 | " 0.010101 \n",
294 | " 0.000000 \n",
295 | " 0.717172 \n",
296 | " 0.0 \n",
297 | " 0.0 \n",
298 | " 78.547485 \n",
299 | " \n",
300 | " \n",
301 | " online \n",
302 | " 0.542553 \n",
303 | " 0.228571 \n",
304 | " 0.028571 \n",
305 | " 0.014286 \n",
306 | " 0.028571 \n",
307 | " 0.000000 \n",
308 | " 0.700000 \n",
309 | " 1.0 \n",
310 | " 0.0 \n",
311 | " 73.635263 \n",
312 | " \n",
313 | " \n",
314 | "
\n",
315 | "
"
316 | ],
317 | "text/plain": [
318 | " gender asian black hawaiian hispanic unknown \\\n",
319 | "class_format \n",
320 | "blended 0.550459 0.217949 0.102564 0.025641 0.012821 0.012821 \n",
321 | "face_to_face 0.633333 0.202020 0.070707 0.000000 0.010101 0.000000 \n",
322 | "online 0.542553 0.228571 0.028571 0.014286 0.028571 0.000000 \n",
323 | "\n",
324 | " white format_ol format_blended falsexam \n",
325 | "class_format \n",
326 | "blended 0.628205 0.0 1.0 77.093731 \n",
327 | "face_to_face 0.717172 0.0 0.0 78.547485 \n",
328 | "online 0.700000 1.0 0.0 73.635263 "
329 | ]
330 | },
331 | "execution_count": 82,
332 | "metadata": {},
333 | "output_type": "execute_result"
334 | }
335 | ],
336 | "source": [
337 | "(data\n",
338 | " .assign(class_format = np.select(\n",
339 | " [data[\"format_ol\"].astype(bool), data[\"format_blended\"].astype(bool)],\n",
340 | " [\"online\", \"blended\"],\n",
341 | " default=\"face_to_face\"\n",
342 | " ))\n",
343 | " .groupby([\"class_format\"])\n",
344 | " .mean())"
345 | ]
346 | },
347 | {
348 | "cell_type": "markdown",
349 | "id": "1a7bc570",
350 | "metadata": {},
351 | "source": [
352 | "너무 간단하죠? 우리는 대면 수업(face_to_face)이 평균 약 78.55점인에 반해, 온라인 수업(online)의 경우 평균 73.63점을 보여주고 있습니다. 온라인 수업을 지지자들에게 좋은 소식은 아니겠네요. 고로 온라인 수업의 $ATE$는 약 -4.91겠네요. 이는 온라인 수업을 듣는 학생들은 평균적으로 약 5점 낮은 점수를 받는다는 것을 의미합니다. 바로 이거죠. 여러분은 대면 수업을 받을 형편이 되지 않는 가난한 학생들이 온라인 수업을 수강할 것이라고 걱정할 필요가 없습니다. 그러므로 여러분은 다른 처치를 받은 학생들이 그들이 받은 처치가 그 외 다른 처치들과는 다를 것이라고 걱정할 필요는 없다는 것이죠.(어떤 그룹이 편향된 특성을 가지고 있을 것이라고 걱정할 필요가 없다는 것이죠.) 무작위 실험은 바로 이런 차이들을 제거하기 위해 설계되었습니다.\n",
353 | "\n",
354 | "이러한 이유들로 인해 랜덤화(randomisation)가 잘 이루어졌는지(또는 올바른 데이터를 살펴보고 있는지) 확인하는 방법은 처치를 받은 것이 전처리 변수에서 처치를 받지 않은 것과 동일한지를 확인하는 것입니다. 현재 우리가 보고 있는 데이터는 성별과 민족에 대한 정보 또한 가지고 있어 그룹 간에 유사한 패턴이 나타나는지를 볼 수 있습니다. 우리는 `gender`, `asian`, `hispanic` , `white` 변수에서는 비교적 비슷한 결과가 나오는 것을 알 수 있습니다. 하지만 `black` 변수에서는 다른 경향이 보이네요. 이러한 경향은 작은 데이터셋에서 어떤 일이 일어나는지 확인할 수 있게끔 합니다. 무작위 실험을 한다 할지라도, 우연히 한 그룹의 경향성이 다른 그룹과는 다를 수 있습니다. 큰 표본에서는 이러한 차이가 사라지는 편이죠."
355 | ]
356 | },
357 | {
358 | "attachments": {},
359 | "cell_type": "markdown",
360 | "id": "7645a726",
361 | "metadata": {},
362 | "source": [
363 | "## The Ideal Experiment\n",
364 | "\n",
365 | "무작위 실험(Randomised experiments), 무작위 통제 실험(Randomised Controlled Trials: RCT)이 인과 효과(causal effect)를 확인할 수 있는 가장 신뢰할만한 방법입니다. 또한 인과 관계를 가장 직접적으로 확인할 수 있는 기술이며, 엄청난 설득력을 갖추고 있죠. 그렇기 때문에 많은 국가들이 신약의 효과성을 보여주고자 할 때 필수적으로 활용하고 있죠. 조금 더 끔찍한 비유를 하자면, RCT를 아바타(Avatar: The Last Airbender, 아바타: 아앙의 전설, 미국 니켈로디언에서 2005년부터 방영한 애니메이션)의 Aang으로 생각할 수 있습니다. RCT를 제외한 다른 기술들은 Sokka에 더 가깝습니다. Sokka는 매우 멋지고 여기저기서 멋진 묘기를 부릴 수 있지만 Aang은 네 가지 요소(물, 흙, 불, 공기)를 구부려 영적 세계와 연결시킬 수 있습니다. 이렇게 생각해 볼까요? 만약 우리가 할 수 있다면, RCT는 인과 관계를 알아내기 위해 우리가 할 수 있는 모든 것이 될 것입니다. 잘 설계된 RCT는 모든 과학자들의 꿈이라고 할 수 있죠.\n",
366 | "\n",
367 | "\n",
368 | "\n",
369 | "\n",
370 | "\n",
371 | "안타깝게도, RCT 방법론은 비용이 매우 많이 들어간다든지 비윤리성을 가지고 있다든지 하는 한계가 있습니다. 때로는 실험자가 처치를 진행하는 매커니즘을 쉽게 통제하지 못할 때도 있죠. 이렇게 생각해볼까요? 임신 중 흡연이 출산 뒤 아이의 체중에 어떤 영향을 미치는지 측정해보고자 한다고 해봅시다. 우리가 의사라 할지라도 우리는 몇 명의 임산부를 무작위로 선정해 임신 중에 흡연을 하게끔 절대 강요할 수 없을 거에요. 또다른 예시를 들어보자면 여러분이 큰 은행에서 일하고 있고, 신용 한도가 고객의 이탈에 어떠한 영향을 미치는지 추정할 필요가 있다고 해봅시다. 우리의 고객들에게 무작위로 신용 한도를 주는 것에는 너무 큰 비용이 들어갈꺼에요. 또 최저임금 인상이 실업률에 미치는 영향을 조사하고 싶다고요? 우리는 개별 국가들에게 최저 임금을 조정하라고 할 수 없을 거에요. 이제 여러분이 이해하셨을 거라 생각합니다.\n",
372 | "\n",
373 | "이런 방법도 있을 거에요. 우리가 차후에 조건부 무작위 실험을 진행한다 하고 완전 무작위 실험 비용을 낮추는 방법 또한 고려할 수 있겠지만, 비윤리적이거나 실현이 불가능한 실험들에 대해서는 할 수 있는게 여전히 없을 꺼에요. 그럼에도 불구하고, 우리가 인과적인 질문을 던질 때마다, 어떤 것이 **이상적인 실험인가**에 대해 생각하는 것은 여전히 가치 있을 거에요. 항상 스스로에게 질문을 던져보세요. **인과적인 관계를 밝혀낼 때 어떤 것이 완벽한 실험이 될 수 있을 건가에 대해서요.** 그럼으로써 우리는 이상적인 실험 없이도 어떻게 우리가 인과 효과를 발견할 수 있을지에 다가가는 하나의 방법이 될 것입니다.\n",
374 | "\n",
375 | "## The Assignment Mechanism\n",
376 | "\n",
377 | "완전 무작위 실험(Randomised Experiment)에서 누구에게 처치를 진행할 것인가는 완전 랜덤입니다. 다음 아티클들을 통해서도 알게 되겠지만, 모든 인과 추론 기술들은 누구에게 처치를 진행하는지를 알고 싶어 하죠. 만약 우리가 이 매커니즘(Assignment Mechanism)을 잘 이해하게 된다면, 처치가 랜덤이 아니라 할지라도 인과 추론은 더 신뢰할만 할 것입니다. *(assignment mechanism: 측정 가능한 공변량 X가 충분히 주어진다면 처치(Treatment)는 Y(결과)와 관계 없이 랜덤하게 주어진다는 가정)*\n",
378 | "\n",
379 | "안타깝게도 처치가 가해지는 방식(Assignment Mechanism)은 데이터를 살펴본다고 해서 쉽게 발견하긴 어려운 것이죠. 예를 들어 우리가 고등 교육과 부의 상관관계에 대한 데이터를 가지고 있다 하더라도, 데이터를 통해 어떤 것이 원인에 있는지를 쉽게 알긴 어렵습니다. 우리는 우리의 도메인(예를 들어 세상이 어떻게 흘러가는지에 대한 지식)을 활용하여 그럴듯해 보이는 주장을 해야할 것입니다. 이런 주장을 할 수 있겠네요. 학교가 사람들을 교육하고, 그래서 그들을 더 생산적으로 만든다면, 결국 그들을 더 높은 임금을 받는 직업으로 이끄는 것일까? 아니면 여러분이 교육에 대해 비관적이라면, 학교는 생산성을 높이기 위해 그 어떤 것도 하지 않는다고 말할 수도 있겠네요. 그리고 이건 사실 있어보이기만 한 상관관계죠. 왜냐하면 부유한 가정들에서만 그들의 자식들을 높은 학위를 받게하기 위한 교육을 할 여유가 있기 때문이죠.\n",
380 | "\n",
381 | "인과적 질문에서는 우리는 두 가지의 논쟁을 하게 될 것이죠. 'X가 Y의 원인'이라고 하거나, '제 3의 변수인 Z가 X와 Y의 원인이기 때문에 X와 Y의 상관 관계는 거짓이다'와 같은 것들이요. 이러한 이유들로 인해 우리가 Assignment Mechanism에 대해 잘 알게 된다면, 우리는 훨씬 더 설득력 있는 인과적 답변을 할 수 있을 것입니다. 바로 이런 것들이 인과 추론을 더더욱 재미있게 만드는 것이죠! 머신 러닝은 적절한 순서에 따라 버튼들을 누르는 것에 불과하지만, 인과 추론은 데이터가 생산되는 과정에 대해 진지한 사고를 요하는 것이죠.\n",
382 | "\n",
383 | "## Key Ideas\n",
384 | "\n",
385 | "우리는 지금까지 무작위 실험이 왜 인과적 영향을 추론하는 가장 간단하고 가장 효과적인 방법인지를 살펴보았습니다. 바로 실험군(T-group)과 대조군(C-group)을 비교 가능하게끔 만들어 주는 것이죠. 슬프게도 우리는 무작위 실험을 항상 할 순 없지만, 우리가 할 수 있는 이상적인 실험이 무엇인지를 생각하는 것은 여전히 도움이 됩니다.\n",
386 | "\n",
387 | "통계에 익숙한 누군가는 지금 제가 인과 관계의 추정치에 대해 살펴보지 않았다고 항의하고 있을 수도 있습니다. 4.91점의 하락이 우연에 의해 일어난 것이 아니라는 것을 어떻게 알 수 있나요? 그 차이가 통계적으로 유의한지 어떻게 알 수 있나요? 모두 타당한 말씀 질문입니다. 아직 다뤄야할 부분들이 남아있으니, 걱정하지 마세요. 곧 통계적 개념들에 대해 다룰 예정이니까요!\n",
388 | "\n",
389 | "## References\n",
390 | "\n",
391 | "이 책을 쓰기 위해 Joshua Angrist, Alberto Abadie, Christopher Walters의 대단한 계량 경제학 수업 자료를 많이 참고했습니다. 해당 자료에 있는 대부분의 아이디어는 전미경제학회(American Economic Association)의 수업에서 가져왔어요. 이렇게 좋은 참고자료를 보는 것이 2020년의 힘든 한 해를 지탱하게 만들어준 원동력이었다고 생각해요.\n",
392 | "\n",
393 | "* [Cross-Section Econometrics](https://www.aeaweb.org/conference/cont-ed/2017-webcasts)\n",
394 | "* [Mastering Mostly Harmless Econometrics](https://www.aeaweb.org/conference/cont-ed/2020-webcasts)\n",
395 | "\n",
396 | "또한, Angrist의 정말 좋은 책들을 참고자료에 넣고 싶어요. 해당 저자가 쓴 책들은 계량경제학(Econometrics) 또는 '메트릭스(Metrics, 계량적 분석)'가 매우 유용할 뿐만 아니라 매우 흥미롭다는 걸 알려주었어요.\n",
397 | "\n",
398 | "* [Mostly Harmless Econometrics](https://www.mostlyharmlesseconometrics.com/)\n",
399 | "* [Mastering ‘Metrics](https://www.masteringmetrics.com/)\n",
400 | "\n",
401 | "마지막으로 참고한 자료는 Miguel Hernan과 Jamie Robins의 책입니다. 이 책들은 제가 대답해야 했던 까다로운 인과적인 질문에서 신뢰할 수 있는 동반자 같은 존재였어요.\n",
402 | "\n",
403 | "* [Causal Inference Book](https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/)\n",
404 | "\n",
405 | "Alpert, William T., Kenneth A. Couch, and Oskar R. Harmon. 2016의 연구 데이터를 활용하였습니다. “[A Randomized Assessment of Online Learning](https://www.aeaweb.org/articles?id=10.1257/aer.p20161057)” American Economic Review, 106(5): 378-82입니다.\n",
406 | "\n",
407 | "\n",
408 | "\n",
409 | "## Contribute\n",
410 | "\n",
411 | "Causal Inference for the Brave and True는 인과추론, 통계학에 대한 오픈소스 자료입니다. 이 자료는 금전적으로나 모든 분들이 쉽게 접근하실 수 있도록 하는 것이 목표입니다. 또한, 이 책은 Python 기반의 무료 소프트웨어만 사용해요.\n",
412 | "여러분들께서 이 자료가 가치 있다고 생각하시고, 금전적으로 지원을 원하신다면 [Patreon](https://www.patreon.com/causal_inference_for_the_brave_and_true)를 방문해주세요. \n",
413 | "만약 여러분이 금전적으로 기여하기가 쉽지 않으시다면, 오타 수정, 수정 제안, 이해하기 난해한 부분에 대한 피드백 제공 등을 통해 도움을 주실 수 있어요. 이 책의 Github 저장소 [이슈 페이지](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/issues)를 방문해주세요. 마지막으로 이 자료가 여러분의 마음에 드셨다면 도움이 될 수 있는 다른 사람들과 공유해주시고, [한국어 번역 자료](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/stargazers)와 [해당 번역본의 원서](https://github.com/matheusfacure/python-causality-handbook/stargazers)에 star 부탁드립니다!"
414 | ]
415 | }
416 | ],
417 | "metadata": {
418 | "kernelspec": {
419 | "display_name": "Workspace_JS",
420 | "language": "python",
421 | "name": "python3"
422 | },
423 | "language_info": {
424 | "codemirror_mode": {
425 | "name": "ipython",
426 | "version": 3
427 | },
428 | "file_extension": ".py",
429 | "mimetype": "text/x-python",
430 | "name": "python",
431 | "nbconvert_exporter": "python",
432 | "pygments_lexer": "ipython3",
433 | "version": "3.9.7"
434 | },
435 | "vscode": {
436 | "interpreter": {
437 | "hash": "a812027cb36d52afc6bf34b1f842ed1960d479f5dea7272b4a52eb53764f32d8"
438 | }
439 | }
440 | },
441 | "nbformat": 4,
442 | "nbformat_minor": 5
443 | }
444 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/09-Non-Compliance-and-LATE.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "metadata": {},
7 | "source": [
8 | "# 09 - Non Compliance and LATE\n",
9 | "\n",
10 | "## \"Heterogeneous\"의 세계에 발을 담가봅시다\n",
11 | "\n",
12 | "이전 챕터에서 전통적인 관점으로부터 도구 변수에 대해 배웠습니다. 도구변수(IV)는 우리가 활용할 수 있는 대표적인 Natural Experiment(*Exogenous shock에 의한 준실험)으로 여겨졌습니다. 한편, IV를 활용한 의학 실험에서 저희는 많은 통찰을 얻을 수 있었습니다. 바로 도구변수에 어떻게 반응하느냐에 따라 4가지 종류의 집단으로 나누는 것입니다.\n",
13 | "\n",
14 | "1. Compliers\n",
15 | "2. Never Takers\n",
16 | "3. Always Takers\n",
17 | "4. Defieres\n",
18 | "\n",
19 | "해당 명칭은 약학(Pharmaceutical science)으로 부터 왔습니다. 여러분이 어떤 질병에 대한 신약 효과를 테스트하기 위해 실험을 수행하고 있다고 가정해봅시다. 각 피실험자는 진짜 약물 또는 위약을 할당 받습니다. 여기서 Compliers는 할당된 약물 또는 위약을 거부감 없이 복용하는 집단을 말합니다. 만약 Compliers가 진짜 약을 할당 받으면, 거부없이 복용할 것이고 반대도 마찬가지 일 것입니다. Never Takers는 할당 받은 약의 복용(Treatment)을 거부 또는 받지 않는 사람입니다. Never Takers는 어떠한 약을 할당받아도 복용하지 않을 겁니다. 반면에 Always taker는 약 할당과 별개로 항상 진짜 약물을 복용하는 사람들입니다. 마지막으로 Defiers는 통제에 할당되면 Treatment를 받고, Treatment를 할당 받으면 통제를 받는 즉, 할당과 반대로 움직이는 청개구리 아이라고 생각하시면 됩니다. 실제 상황에서는 Defiers는 그렇게 일반적이지 않아서 무시하고 진행합니다.\n",
20 | "\n",
21 | "\n",
22 | "\n",
23 | " 현대의 IV 실험에서는 활용하는 도구(instrument)를 위에서 분류한 4가지 compliance를 완벽하게 고려하지 않은 준실험 설계로 생각합니다(Compliers 그룹에만 해당하는 인과 효과만을 고려). 즉, 도구변수를 활용한 실험은 내부적으로 유효한 인과 효과와 외부적으로 유효한 인과 효과를 구분시킵니다. 기억하세요! 내부적으로만 유효한 인과효과는 특정 데이터 그리고 특정 실험 세팅에서만 유효합니다. IV 실험에서는 설정한 도구변수를 활용해 Treatment가 변하는 사람들에게 대한 처치효과가 될 것입니다. 반면에 외적 타당도(External validity)는 그 인과적 효과의 예측력과 관련이 있습니다. 이는 우리가 실험한 표본에서 발견한 효과를 다른 모집단에 대해 일반화할 수 있는지에 대한 질문입니다. 예를 들어, 기부에 대한 인센티브가 주어졌을 때 사람들이 얼마나 기부를 할지에 대해 실험을 설계했다고 가정해 보겠습니다. 실험은 잘 설계 되었으며, 실험 대상자로 경제학과 학생들만 참여하도록 합니다. 그렇다면 실험에서 경제학도는 이기주의자(selfish jerks)라는 것을 발견할 것입니다. 이러한 사실은 비록 실험 내적으로 유효한 결론이지만, 해당 데이터 포인트에서만 유효하며 이 실험의 결과를 통해 인류가 이기적이라고 추론할 수 없습니다. 따라서 우리는 해당 실험이 과연 외부적 타당성을 가지고 있는지에 대한 의문을 가질 수 있습니다. \n",
24 | "\n",
25 | " 다시 도구변수로 돌아와서, 여러분은 회사에서 인앱 구매로 측정한 사용자 참여(user engagement) 지표를 높이고 싶다고 가정해봅시다. user engagement를 늘리기 위해 마케팅 부서에 engagement를 늘리는 push 마케팅을 요청할 수 있겠죠. 마케팅팀에서 push 디자인과 설계를 잘해서 10000명의 무작위 고객을 선택하여 각 50%의 확률로 push를 할당합니다. 하지만 이러한 테스트를 진행할 때, 일부 고객이 Push를 거부하여 받지 못할 수 있습니다. 또는 고객의 스마트폰이 구형 스마트폰일 수도 있구요. \n",
26 | " 처음에는 이러한 차이가 별거 아니라고 생각할 수 있지만, 인과 추론의 문제에서 그렇게 간단한 문제는 아닙니다. 실험을 설계할 때 설정한 처지 변수(Treatment variable)를 활용하는 것 대신 받은 처치(treatment received) 활용하면 됩니다. 이는 인과 그래프로 표현하면 다음과 같습니다."
27 | ]
28 | },
29 | {
30 | "cell_type": "code",
31 | "execution_count": 2,
32 | "metadata": {
33 | "tags": [
34 | "hide-input"
35 | ]
36 | },
37 | "outputs": [],
38 | "source": [
39 | "import warnings\n",
40 | "warnings.filterwarnings('ignore')\n",
41 | "\n",
42 | "import pandas as pd\n",
43 | "import numpy as np\n",
44 | "from scipy import stats\n",
45 | "from matplotlib import style\n",
46 | "import seaborn as sns\n",
47 | "from matplotlib import pyplot as plt\n",
48 | "import statsmodels.formula.api as smf\n",
49 | "from linearmodels.iv import IV2SLS\n",
50 | "import graphviz as gr\n",
51 | "\n",
52 | "%matplotlib inline\n",
53 | "\n",
54 | "style.use(\"fivethirtyeight\")"
55 | ]
56 | },
57 | {
58 | "cell_type": "code",
59 | "execution_count": 3,
60 | "metadata": {
61 | "tags": [
62 | "hide-input"
63 | ]
64 | },
65 | "outputs": [
66 | {
67 | "data": {
68 | "image/svg+xml": "\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\npush assigned \r\n\r\npush assigned \r\n \r\n\r\n\r\npush delivered \r\n\r\npush delivered \r\n \r\n\r\n\r\npush assigned->push delivered \r\n \r\n \r\n \r\n\r\n\r\nin app purchase \r\n\r\nin app purchase \r\n \r\n\r\n\r\npush delivered->in app purchase \r\n \r\n \r\n \r\n\r\n\r\nincome \r\n\r\nincome \r\n \r\n\r\n\r\nincome->push delivered \r\n \r\n \r\n \r\n\r\n\r\nincome->in app purchase \r\n \r\n \r\n \r\n \r\n \r\n",
69 | "text/plain": [
70 | ""
71 | ]
72 | },
73 | "execution_count": 3,
74 | "metadata": {},
75 | "output_type": "execute_result"
76 | }
77 | ],
78 | "source": [
79 | "g = gr.Digraph()\n",
80 | "\n",
81 | "g.edge(\"push assigned\", \"push delivered\")\n",
82 | "g.edge(\"push delivered\", \"in app purchase\")\n",
83 | "g.edge(\"income\", \"in app purchase\")\n",
84 | "g.edge(\"income\", \"push delivered\")\n",
85 | "g.node(\"income\", color=\"blue\")\n",
86 | "g"
87 | ]
88 | },
89 | {
90 | "cell_type": "markdown",
91 | "metadata": {},
92 | "source": [
93 | "\n",
94 | "위의 인과관계 그래프에서 마케팅 Push에 대한 할당이 있습니다. 이러한 Push Assigned는 무작위 할당이기 때문에, 다른 영향을 받지 않습니다. 이후 마케팅 Push의 전달 여부에 대한 노드가 있습니다. Push를 받도록 할당된 모든 사람이 Push를 받은건 아니기 때문에 이 마케팅 실험에서는 Compliance를 완벽하게 고려하지 못합니다. 좀 더 구체적으로 말하면, Push 마케팅을 진행하여도 절대로 해당 Push를 받지 않는 사람들이 존재합니다(Never takers). 즉, Push를 받도록 할당이 되어도 실험의 Treatment인 Push를 받지 못하는 사람들이 있습니다. 또한 이는 단순한 우연이 아닙니다. 예를 들어, 오래된 스마트폰을 가진 사람들은 Push를 받지 못하며, 이러한 사람들의 수입은 최신 스마트폰을 가진 사람들과 다르게 Push 메세지의 전달에 영향을 줄 수 있습니다. 마지막으로 Outcome variable 노드로 인앱 구매(in app purchase)가 있습니다. 기억하세요! 위 인과 그래프에서 우리는 Push를 할당 받는 사람들의 소득을 모르기 때문에, 이러한 변수를 통제할 수 없습니다. \n",
95 | "\n",
96 | "개인의 소득(Income)을 통제할 수 없다는 것을 엳무에 두고 단순히 Push assigned을 처치(Treatment)로 두고 인앱 구매에 대한 인과 관계를 추정해보겠습니다.\n",
97 | "첫 번째의 경우에는 아래와 같이 평균 차이로 인과 관계를 추정합니다.\n",
98 | "\n",
99 | "$\n",
100 | "ATE = E[Y | pushAssigned=1] - E[Y | pushAssigned=0]\n",
101 | "$\n",
102 | "\n",
103 | "우리가 앞에서 배운것과 같이 만약 $E[Y_0|pushAssigned=0] - E[Y_0|pushAssigned=1]$ 에 대한 Bias가 0이라면 $E[Y_1] - E[Y_0]$ 가 Unbiased estimator 입니다. `pushAssigned` 가 랜덤이기 때문에 Bias는 0가 됩니다. 과연 이것으로 충분할까요? 정답은 아닙니다. 만약 이렇게 한다면 우리가 실제로 의도한 것과 다른 질문에 대한 답을 한것입니다. 우리가 찾은 것은 Treatment 자체의 효과가 아니라 Treatment 할당에 대한 인과적 효과를 찾은 것입니다. 그럼 과연 우리가 ATE에 대한 Treatment 할당의 인과적 영향을 추정할 수 있는가? 다른 말로 Treatment 할당의 인과 효과가 우리가 구하고자 하는 ATE의 편향되지 않은 추정치라고 말할 수 있을까요?\n",
104 | "\n",
105 | "결과적으로 그렇지 않습니다. non-Compliance 때문에 Treatment에 할당된 사람들에 대한 결과는 Control에 배정된 사람들의 결과로 편향되어 추정될 것입니다. 이렇게 Non Compliance는 의도하지 않게 Treatment에 대한 결과를 뒤집고 Treatment와 Control에 대한 추정량을 유사하게 만듭니다. 이것을 변수(Variable)에 대한 유사성과 혼동하면 안됩니다. 왜냐하면 변수에 대해 Treatment와 Control이 유사하여야, Comparable 가정을 만족할 수 있으니까요. 우리가 원하지 않는 결과는 실제로는 Treatment 효과가 있지만, Outcome에 대한 효과가 비슷해지는 것입니다\n",
106 | "\n",
107 | "이를 확인하기 위해 먼저 Always taker가 있다고 가정합니다. 그들 중 일부는 우연히 Control에 할당됩니다. 하지만 Always taker는 할당과 상관 없이 Treatment를 받을 것입니다. 이러한 행동은 이 그룹을 Contorl 그룹과 효과가 섞인 Treatment 그룹으로 만듭니다. 이러한 혼합의 결과로 우리는 non-compliance를 가지고 있을때 인과 효과를 찾기가 더욱 어려워 집니다.\n",
108 | "\n",
109 | "\n",
110 | "\n",
111 | "같은 논리로, Never Taker는 Treatment에 배정되더라도 Treatment를 받지 않기 때문에 Treatment에 배정된 사람들이 실제로 Treatment를 받지 않은것 처럼 만들 것입니다. 이러한 의미에서 non-compliance가 인과의 효과를 감소시켜 Treatment 할당의 인과효과는 0으로 편향됩니다. 극단적인 예를 가정하여 이러한 편향을 볼 수도 있습니다. 실험에서 non compliance의 비율이 높다고 생각한다면, non compliance가 Treatment 할당을 받으면 그들은 Treatment의 효과에 대해 아무런 반응이 없을 것입니다. 이러한 경우 할당받은 Treatment는 완전히 랜덤입니다. IV의 관점에서, 우리는 매우 약간 1st stage를 가지고 있다고 말할 수 있습니다. 'Z'를 활용해 Treatment를 표현하면 다음과 같이 표현할 수 있습니다.\n",
112 | "\n",
113 | "$\n",
114 | "E[Y|Z=1] - E[Y|Z=0] = 0\n",
115 | "$\n",
116 | "\n",
117 | "그림에서 볼 수 있듯, Treatment 인과 관계는 더 이상 존재하지 않으며, 여기서 'Z'는 의미 없는 무작위 변수일 뿐입니다.\n"
118 | ]
119 | },
120 | {
121 | "cell_type": "code",
122 | "execution_count": 4,
123 | "metadata": {
124 | "tags": [
125 | "hide-input"
126 | ]
127 | },
128 | "outputs": [
129 | {
130 | "data": {
131 | "image/svg+xml": "\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\npush assigned \r\n\r\npush assigned \r\n \r\n\r\n\r\npush delivered \r\n\r\npush delivered \r\n \r\n\r\n\r\nin app purchase \r\n\r\nin app purchase \r\n \r\n\r\n\r\npush delivered->in app purchase \r\n \r\n \r\n \r\n\r\n\r\nincome \r\n\r\nincome \r\n \r\n\r\n\r\nincome->push delivered \r\n \r\n \r\n \r\n\r\n\r\nincome->in app purchase \r\n \r\n \r\n \r\n \r\n \r\n",
132 | "text/plain": [
133 | ""
134 | ]
135 | },
136 | "execution_count": 4,
137 | "metadata": {},
138 | "output_type": "execute_result"
139 | }
140 | ],
141 | "source": [
142 | "g = gr.Digraph()\n",
143 | "\n",
144 | "g.node(\"push assigned\")\n",
145 | "g.edge(\"push delivered\", \"in app purchase\")\n",
146 | "g.edge(\"income\", \"in app purchase\")\n",
147 | "g.edge(\"income\", \"push delivered\")\n",
148 | "g.node(\"income\", color=\"blue\")\n",
149 | "g"
150 | ]
151 | },
152 | {
153 | "cell_type": "markdown",
154 | "metadata": {},
155 | "source": [
156 | "그래서 우리는 Treatment의 인과적 효과를 추정하는 방법으로 Push assigned에 대한 인과적 효과를 제거했습니다. 그렇다면 Push delivered에 대한 Treatemnt를 활용해보는건 어떨까요?\n",
157 | "\n",
158 | "$\n",
159 | "ATE = E[Y | push=1] - E[Y | push=0]\n",
160 | "$\n",
161 | "\n",
162 | "다시 한 번 우리는 이것이 편향된 것인지, 아니면 \n",
163 | "$E[Y_0|push=0] = E[Y_0|push=1]$ 인지 생각해볼 필요가 있습니다. \n",
164 | "여기서는 측정되지 않은 Confounder 수입(income)이 분명히 인과추론을 어렵게 할 수 있습니다. 앞서 말했듯이, Push 전달의 실패는 구형 스마트폰을 가진 고객들에 의해 발생한다는 것을 알고 있습니다. 즉, $E[Y_0|push=0] < E[Y_0|push=1]$ 가 존재할 수 있습니다. 비교적 적은 수입(income)을 가진 고객들은 구형 스마트폰을 가지고 있기 때문에 $push=0$ 로 이어지고, 인앱 구매 $Y_0$ 의 가능성도 낮습니다.\n",
165 | "\n",
166 | "따라서 Treatment나 Treatment를 받지 않는 사람을 이용해서 ATE를 추정할수 없습니다.\n",
167 | "\n",
168 | "하지만 다행이 도구변수를 활용할 수 있습니다. 여기서 Treatment에 대한 할당 여부는 완벽한 도구변수로 활용할 수 있습니다. 이는 랜덤과 같으며 Treatment으로 인해 앱 내 구매만을 유도합니다. \n",
169 | "\n",
170 | "## Local Average Treatment Effect: LATE\n",
171 | "\n",
172 | "Local average treatment effect는 인과 관계를 추정할 수 있는 모집단을 명시적으로 만듭니다. LATE는 IV를 바라보는 또 다른 관점으로 새로운 직관을 제공해줍니다. IV에서 우리는 도구변수를 인과 사슬(causal chain)의 시작점으로 봅니다. 즉, Z는 Y를 일으키는 T를 유발합니다. 이러한 관점에서 Z가 T에 대한 영향을 주지 않는 한 Z가 Y의 인과가 아닌것을 의미합니다. 1단계에서는 T에 대한 Z의 인과효과로 볼 수 있습니다. 또한 이중 인덱스 표기법(double indexing notation)으로 Potential outcomes를 다시 작성하는데, 여기서 첫 번째 인덱스는 도구변수에 대한 반사실성을 나타내며 두 번째 인덱스는 Treatment에 대한 반사실성을 나타냅니다.\n",
173 | "\n",
174 | "$\n",
175 | "\\text{Potential Outcome}=\\begin{cases}\n",
176 | "Y_i(1, 1) \\ \\text{if } T_i=1, \\ Z_i=1\\\\\n",
177 | "Y_i(1, 0) \\ \\text{if } T_i=1, \\ Z_i=0\\\\\n",
178 | "Y_i(0, 1) \\ \\text{if } T_i=0, \\ Z_i=1\\\\\n",
179 | "Y_i(0, 0) \\ \\text{if } T_i=0, \\ Z_i=0\\\\\n",
180 | "\\end{cases}\n",
181 | "$\n",
182 | "\n",
183 | "이러한 점에서 볼 때, Treatment는 첫 번째 단계에서 Outcome이 됩니다. 이것은 우리가 아래와 같이 Potential outcome framework로 작성할 수 있다는 것을 의미합니다.\n",
184 | "\n",
185 | "$\n",
186 | "\\text{Potential Treatment}=\\begin{cases}\n",
187 | "T_0 \\ \\text{if } Z_i=0 \\\\\n",
188 | "T_1 \\ \\text{if } Z_i=1\n",
189 | "\\end{cases}\n",
190 | "$\n",
191 | "\n",
192 | "\n",
193 | "\n",
194 | "이제 Instrumental Variable 가정을 아래와 같이 다시 작성할 수 있습니다.\n",
195 | "\n",
196 | "1. $T_{0i}, T_{1i} \\perp Z_i $ and $Y_i(T_{1i},1), Y_i(T_{0i},0) \\perp Z_i $. 이는 독립성 가정(independence Assumption) 입니다. 즉, 도구가 무작위로 할당된 것과 같다는 의미입니다. 다시 말해, 도구변수 Z는 잠재적인 Treatment와 상관관계가 없으며, 이는 다른 도구변수 그룹에 속한 사람과 비교가능(Comparable)하다는 것을 말합니다. \n",
197 | "\n",
198 | "2. $Y_i(1, 0)=Y_i(1, 1)=Y_{i1}$ and $Y_i(0, 0)=Y_i(0, 1)=Y_{i0}$. 이 수식은 배제 제약(exclusion restriction)입니다. Treatment에 대한 잠재적인 결과는 두 도구 변수 그룹 모두 동일하다는 것입니다. 즉, 도구 변수는 잠재적인 결과에 영향을 미치지 않으며, 이는 도구 변수가 Treatment를 통해서만 결과에 영향을 미친다는 것과 같습니다.\n",
199 | "\n",
200 | "3. $E[T_{1i}-T_{0i}] \\neq 0$. 이는 1단계의 잠재 결과, 즉 잠재적인 Treatment가 같지 않다는 것을 의미합니다. 또 다른 표현으로는 도구 변수가 Treatment에 영향을 미친다는 것입니다.\n",
201 | "\n",
202 | "\n",
203 | "4. $T_{i1} > T_{i0}$. 이는 도구 변수의 단조성 가정 (monotonicity)입니다. 모든 그룹에서 도구 변수를 활용한다면, Treatment가 꺼진 경우보다 Treatment에 대한 level이 더 높아 진다는 것을 의미합니다. \n",
204 | "\n",
205 | "이제, Wald 추정기를 통해 IV에 대한 추가적인 직관을 얻어봅시다.\n",
206 | "\n",
207 | "$\n",
208 | "ATE = \\dfrac{E[Y|Z=1]-E[Y|Z=0]}{E[T|Z=1]-E[T|Z=0]}\n",
209 | "$\n",
210 | "\n",
211 | "첫번재 부분인 $E[Y|Z=1]$ 을 우선 살펴보겠습니다. 배제 제약(exclusion restriction)을 활용해 Potential outcome Framework의 관점에서 Y를 다시 작성할 수 있습니다.\n",
212 | "\n",
213 | "$\n",
214 | "E[Y_i|Z_i=1]=E[Y_{i0} + T_{i1}(Y_{i1} - Y_{i0})|Z=1]\n",
215 | "$\n",
216 | "\n",
217 | "그리고 독립성 가정(independence Assumption)을 이용하여 Z에 대한 조건화를 제거할 수 있습니다.\n",
218 | "\n",
219 | "$\n",
220 | "E[Y_i|Z_i=1]=E[Y_{i0} + T_{i1}(Y_{i1} - Y_{i0})]\n",
221 | "$\n",
222 | "\n",
223 | "비슷하게, 우리는 아래와 같은 식을 얻을 수 있습니다.\n",
224 | "\n",
225 | "$\n",
226 | "E[Y_i|Z_i=0]=E[Y_{i0} + T_{i0}(Y_{i1} - Y_{i0})]\n",
227 | "$\n",
228 | "\n",
229 | "Wald 추정기의 분자를 다음과 같이 다시 써봅시다.\n",
230 | "\n",
231 | "$\n",
232 | "E[Y|Z=1]-E[Y|Z=0] = E[(Y_{i1}-Y_{i0})(T_{i1}-T_{i0})]\n",
233 | "$\n",
234 | "\n",
235 | "도구변수의 단조성 가정을 활용한다면, $T_{i1}-T_{i0}$ 이 0 또는 1이라는 것을 알 수 있습니다. 따라서,\n",
236 | "\n",
237 | "$\n",
238 | "E[(Y_{i1}-Y_{i0})(T_{i1}-T_{i0})] = E[(Y_{i1}-Y_{i0})|T_{i1}>T_{i0}]P(T_{i1}>T_{i0})\n",
239 | "$\n",
240 | "\n",
241 | "이제 분모를 처리하기 위해 비슷한 방법으로, 아래와 같은 식을 얻을 수 있습니다.\n",
242 | "\n",
243 | "$\n",
244 | "E[T|Z=1]-E[T|Z=0]=E[T_{i1}-T_{i0}]=P(T_{i1}>T_{i0})\n",
245 | "$\n",
246 | "\n",
247 | "즉, 위의 과정을 통해 다음과 같이 Wald 추정기를 확인할 수 있습니다.\n",
248 | "\n",
249 | "$\n",
250 | "ATE = \\dfrac{E[(Y_{i1}-Y_{i0})|T_{i1}>T_{i0}]P(T_{i1}>T_{i0})}{P(T_{i1}>T_{i0})}=E[(Y_{i1}-Y_{i0})|T_{i1}>T_{i0}]\n",
251 | "$\n",
252 | "\n",
253 | "즉, IV에 의해 추정된 ATE는 $T_{i1}>T_{i0}$ 인 부분 모집단의 ATE입니다. 그리고 compliance에 대해서 생각해보면, 어떠한 집단이 이에 해당할까요? 이 집단은 도구 변수를 설정한 사용자가 도구 변수를 해제한 경우보다 Treatment에 대한 수준이 높은 모집단입니다. 즉, Complier 입니다. \n",
254 | "\n",
255 | "1. Compilers $T_{i1}>T_{i0}$ \n",
256 | "2. Never Takers $T_{i1}=T_{i0}=0$\n",
257 | "3. Always Takers $T_{i1}=T_{i0}=1$\n",
258 | "\n",
259 | "결론은, IV는 Never Taker, Always Takers 또는 defiers에 미치는 영향에 대해서는 말을 해주지 않는다는 것입니다. 왜냐하면 그들의 Treatment가 변화되지 않으니깐요. 즉, IV는 Comilers에 대한 Treatment 효과를 찾아줍니다. \n",
260 | "\n",
261 | "\n",
262 | "## Effect on Engagement\n",
263 | "\n",
264 | "다시 돌아와서, 앱 내 구매에 대한 Push 효과를 추정하는 사례에서 위에서 배운 것이 어떻게 진행되는지 알아보겠습니다.\n",
265 | "\n",
266 | "인과 그래프는 위에서 본것과 동일하기 때문에 여기서 반복하지는 않겠습니다. 우리가 가지고 있는 데이터는 Push 할당과 Push 전달에 대한 Treatment 변수 그리고 in app의 구매에 대한 정보입니다."
267 | ]
268 | },
269 | {
270 | "cell_type": "code",
271 | "execution_count": 7,
272 | "metadata": {
273 | "tags": [
274 | "hide-input"
275 | ]
276 | },
277 | "outputs": [
278 | {
279 | "data": {
280 | "text/html": [
281 | "\n",
282 | "\n",
295 | "
\n",
296 | " \n",
297 | " \n",
298 | " \n",
299 | " in_app_purchase \n",
300 | " push_assigned \n",
301 | " push_delivered \n",
302 | " \n",
303 | " \n",
304 | " \n",
305 | " \n",
306 | " 0 \n",
307 | " 47 \n",
308 | " 1 \n",
309 | " 1 \n",
310 | " \n",
311 | " \n",
312 | " 1 \n",
313 | " 43 \n",
314 | " 1 \n",
315 | " 0 \n",
316 | " \n",
317 | " \n",
318 | " 2 \n",
319 | " 51 \n",
320 | " 1 \n",
321 | " 1 \n",
322 | " \n",
323 | " \n",
324 | " 3 \n",
325 | " 49 \n",
326 | " 0 \n",
327 | " 0 \n",
328 | " \n",
329 | " \n",
330 | " 4 \n",
331 | " 79 \n",
332 | " 0 \n",
333 | " 0 \n",
334 | " \n",
335 | " \n",
336 | "
\n",
337 | "
"
338 | ],
339 | "text/plain": [
340 | " in_app_purchase push_assigned push_delivered\n",
341 | "0 47 1 1\n",
342 | "1 43 1 0\n",
343 | "2 51 1 1\n",
344 | "3 49 0 0\n",
345 | "4 79 0 0"
346 | ]
347 | },
348 | "execution_count": 7,
349 | "metadata": {},
350 | "output_type": "execute_result"
351 | }
352 | ],
353 | "source": [
354 | "data = pd.read_csv(\"./data/app_engagement_push.csv\")\n",
355 | " \n",
356 | "data.head()"
357 | ]
358 | },
359 | {
360 | "cell_type": "markdown",
361 | "metadata": {},
362 | "source": [
363 | "첫 번째로, OLS가 어떠한 결과가 나오는지 확인해보죠."
364 | ]
365 | },
366 | {
367 | "cell_type": "code",
368 | "execution_count": 8,
369 | "metadata": {
370 | "tags": [
371 | "hide-input"
372 | ]
373 | },
374 | "outputs": [
375 | {
376 | "data": {
377 | "text/html": [
378 | "\n",
379 | "Parameter Estimates \n",
380 | "\n",
381 | " Parameter Std. Err. T-stat P-value Lower CI Upper CI \n",
382 | " \n",
383 | "\n",
384 | " Intercept 69.292 0.3624 191.22 0.0000 68.581 70.002 \n",
385 | " \n",
386 | "\n",
387 | " push_assigned -17.441 0.5702 -30.590 0.0000 -18.559 -16.324 \n",
388 | " \n",
389 | "\n",
390 | " push_delivered 27.600 0.6124 45.069 0.0000 26.399 28.800 \n",
391 | " \n",
392 | "
"
393 | ],
394 | "text/plain": [
395 | ""
396 | ]
397 | },
398 | "execution_count": 8,
399 | "metadata": {},
400 | "output_type": "execute_result"
401 | }
402 | ],
403 | "source": [
404 | "ols = IV2SLS.from_formula(\"in_app_purchase ~ 1 + push_assigned + push_delivered\", data).fit()\n",
405 | "ols.summary.tables[1]"
406 | ]
407 | },
408 | {
409 | "cell_type": "markdown",
410 | "metadata": {},
411 | "source": [
412 | "OLS에서 Treatment 효과 BRL(bias-reduced linearization)는 27.60이며, 이는 Push 마케팅을 진행하면 인앱 구매가 27.6 만큼 오른다는 것을 의미합니다. 그러나 우리는 이것이 편향된 추정치라고 믿을만한 근거가 있습니다. 앞선 설명과 같이 옛날 스마트폰이 Push 메세지를 받기에 어려움을 겪고 있다는 것이죠. 그래서 비교적 부유한 고객들이 바로 새로운 전화기를 가진 Compiler일 것입니다. 즉, Treatment 받는 사람들은 더 많은 수입이 있기 때문에 우리는 이러한 편향이 Positive일 것이며, 실제 인과 효과는 더 낮다고 생각할 수 있습니다. 수식으로 표현해보면, $E[Y_0|T=0] < E[Y_0|T=1]$ 이 존재할 수 있습니다.\n",
413 | "\n",
414 | "이제, 도구변수를 활용해서 해당 효과를 추정해 보겠습니다. 먼저 첫번째 Stage를 진행해보겠습니다."
415 | ]
416 | },
417 | {
418 | "cell_type": "code",
419 | "execution_count": 9,
420 | "metadata": {
421 | "tags": [
422 | "hide-input"
423 | ]
424 | },
425 | "outputs": [
426 | {
427 | "data": {
428 | "text/html": [
429 | "\n",
430 | "Parameter Estimates \n",
431 | "\n",
432 | " Parameter Std. Err. T-stat P-value Lower CI Upper CI \n",
433 | " \n",
434 | "\n",
435 | " Intercept 2.22e-16 4.09e-10 5.429e-07 1.0000 -8.016e-10 8.016e-10 \n",
436 | " \n",
437 | "\n",
438 | " push_assigned 0.7176 0.0064 112.07 0.0000 0.7050 0.7301 \n",
439 | " \n",
440 | "
"
441 | ],
442 | "text/plain": [
443 | ""
444 | ]
445 | },
446 | "execution_count": 9,
447 | "metadata": {},
448 | "output_type": "execute_result"
449 | }
450 | ],
451 | "source": [
452 | "first_stage = IV2SLS.from_formula(\"push_delivered ~ 1 + push_assigned\", data).fit()\n",
453 | "first_stage.summary.tables[1]"
454 | ]
455 | },
456 | {
457 | "cell_type": "markdown",
458 | "metadata": {},
459 | "source": [
460 | "Push를 받도록 할당된 사람들은 71.8%의 확률로 Push를 받습니다. 이것은 Never takers가 28%가 된다는 것을 의미합니다. 또한 intercept의 Parameter가 0으로 추정되기 때문에 always takers는 없다고 판단할 수 있습니다. 이것은 실제로 Treatment를 할당하지 않은 경우에는 아무도 Push를 받지 못한다는 것을 의미하며, 실험 설계를 고려할 때 예상할 수 있습니다.\n",
461 | "\n",
462 | "다음으로 push_delivered 제거된 식으로 회귀 분석을 진행해보도록 하겠습니다."
463 | ]
464 | },
465 | {
466 | "cell_type": "code",
467 | "execution_count": 10,
468 | "metadata": {
469 | "tags": [
470 | "hide-input"
471 | ]
472 | },
473 | "outputs": [
474 | {
475 | "data": {
476 | "text/html": [
477 | "\n",
478 | "Parameter Estimates \n",
479 | "\n",
480 | " Parameter Std. Err. T-stat P-value Lower CI Upper CI \n",
481 | " \n",
482 | "\n",
483 | " Intercept 69.292 0.3624 191.22 0.0000 68.581 70.002 \n",
484 | " \n",
485 | "\n",
486 | " push_assigned 2.3636 0.5209 4.5376 0.0000 1.3427 3.3845 \n",
487 | " \n",
488 | "
"
489 | ],
490 | "text/plain": [
491 | ""
492 | ]
493 | },
494 | "execution_count": 10,
495 | "metadata": {},
496 | "output_type": "execute_result"
497 | }
498 | ],
499 | "source": [
500 | "reduced_form = IV2SLS.from_formula(\"in_app_purchase ~ 1 + push_assigned\", data).fit()\n",
501 | "reduced_form.summary.tables[1]"
502 | ]
503 | },
504 | {
505 | "cell_type": "markdown",
506 | "metadata": {},
507 | "source": [
508 | "축소된 형식으로 Treatment 할당에 대한 인과 효과는 2.36임을 보여줍니다. 이는 Push를 받을 누군가를 지정하면 인앱 구매가 2.36 만큼 증가한다는 것을 의미합니다. \n",
509 | "\n",
510 | "축소된 형태를 첫 번째 단계로 나누고, instrument의 효과를 Treatment의 단위로 스케일링하면 $2.3636/0.7176=3.29$ 를 얻을 수 있습니다. 2SLS를 실행하면 표준 오차와 함께 이와 동일한 추정치를 얻을 수 있습니다."
511 | ]
512 | },
513 | {
514 | "cell_type": "code",
515 | "execution_count": 11,
516 | "metadata": {
517 | "tags": [
518 | "hide-input"
519 | ]
520 | },
521 | "outputs": [
522 | {
523 | "data": {
524 | "text/html": [
525 | "\n",
526 | "Parameter Estimates \n",
527 | "\n",
528 | " Parameter Std. Err. T-stat P-value Lower CI Upper CI \n",
529 | " \n",
530 | "\n",
531 | " Intercept 69.292 0.3624 191.22 0.0000 68.581 70.002 \n",
532 | " \n",
533 | "\n",
534 | " push_delivered 3.2938 0.7165 4.5974 0.0000 1.8896 4.6981 \n",
535 | " \n",
536 | "
"
537 | ],
538 | "text/plain": [
539 | ""
540 | ]
541 | },
542 | "execution_count": 11,
543 | "metadata": {},
544 | "output_type": "execute_result"
545 | }
546 | ],
547 | "source": [
548 | "iv = IV2SLS.from_formula(\"in_app_purchase ~ 1 + [push_delivered ~ push_assigned]\", data).fit()\n",
549 | "iv.summary.tables[1]"
550 | ]
551 | },
552 | {
553 | "attachments": {},
554 | "cell_type": "markdown",
555 | "metadata": {},
556 | "source": [
557 | "이를 통해 2SLS의 결과가 OLS의 27.6보다 훨씬 낮다는 것을 확인할 수 있습니다. OLS로 추정된 인과 효과는 긍정적으로 편향되어 있으므로 이러한 결과는 타당해 보입니다. 또한 LATE에 대해서도 기억해야 합니다. 3.29는 Complier에 대한 ATE 입니다. 안타깝게도, Never taker에 대해서는 해당 효과를 알 수 없습니다. 다시 말해, 최신 스마트폰을 가지고 있는 그룹에 대하여 해당 Push 마케팅이 미치는 결과를 추정하고 있음을 의미합니다. \n",
558 | "\n",
559 | "## Key Ideas\n",
560 | "\n",
561 | "해당 챕터에서는 Instrumental Variables에 대한 보다 현대적인 관점을 알아봤습니다. 어떻게 IV가 결과를 초래하는 Treatment를 유발하는 인과적 사슬로 볼 수 있는지 배웠어요. 이러한 관점에서 우리는 IV 추정에서 ATE를 이해하기 위해 compliance를 살펴보았으며, 헤딩 compiler에 대한 LATE라는 것을 알아보았습니다. \n",
562 | "\n",
563 | "## References\n",
564 | "\n",
565 | "이 책을 쓰기 위해 Joshua Angrist, Alberto Abadie, Christopher Walters의 대단한 계량 경제학 수업 자료를 많이 참고했습니다. 해당 자료에 있는 대부분의 아이디어는 전미경제학회(American Economic Association)의 수업에서 가져왔어요. 이렇게 좋은 참고자료를 보는 것이 2020년의 힘든 한 해를 지탱하게 만들어준 원동력이었다고 생각해요.\n",
566 | "\n",
567 | "* [Cross-Section Econometrics](https://www.aeaweb.org/conference/cont-ed/2017-webcasts)\n",
568 | "* [Mastering Mostly Harmless Econometrics](https://www.aeaweb.org/conference/cont-ed/2020-webcasts)\n",
569 | "\n",
570 | "또한, Angrist의 정말 좋은 책들을 참고자료에 넣고 싶어요. 해당 저자가 쓴 책들은 계량경제학(Econometrics) 또는 '메트릭스(Metrics, 계량적 분석)'가 매우 유용할 뿐만 아니라 매우 흥미롭다는 걸 알려주었어요.\n",
571 | "\n",
572 | "* [Mostly Harmless Econometrics](https://www.mostlyharmlesseconometrics.com/)\n",
573 | "* [Mastering 'Metrics](https://www.masteringmetrics.com/)\n",
574 | "\n",
575 | "마지막으로 참고한 자료는 Miguel Hernan과 Jamie Robins의 책입니다. 이 책들은 제가 대답해야 했던 까다로운 인과적인 질문에서 신뢰할 수 있는 동반자 같은 존재였어요.\n",
576 | "\n",
577 | "* [Causal Inference Book](https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/)\n",
578 | "\n",
579 | "\n",
580 | "\n",
581 | "## Contribute\n",
582 | "\n",
583 | "Causal Inference for the Brave and True는 인과추론, 통계학에 대한 오픈소스 자료입니다. 이 자료는 금전적으로나 모든 분들이 쉽게 접근하실 수 있도록 하는 것이 목표입니다. 또한, 이 책은 Python 기반의 무료 소프트웨어만 사용해요.\n",
584 | "여러분들께서 이 자료가 가치 있다고 생각하시고, 금전적으로 지원을 원하신다면 [Patreon](https://www.patreon.com/causal_inference_for_the_brave_and_true)를 방문해주세요. \n",
585 | "만약 여러분이 금전적으로 기여하기가 쉽지 않으시다면, 오타 수정, 수정 제안, 이해하기 난해한 부분에 대한 피드백 제공 등을 통해 도움을 주실 수 있어요. 이 책의 Github 저장소 [이슈 페이지](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/issues)를 방문해주세요. 마지막으로 이 자료가 여러분의 마음에 드셨다면 도움이 될 수 있는 다른 사람들과 공유해주시고, [한국어 번역 자료](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/stargazers)와 [해당 번역본의 원서](https://github.com/matheusfacure/python-causality-handbook/stargazers)에 star 부탁드립니다!"
586 | ]
587 | }
588 | ],
589 | "metadata": {
590 | "celltoolbar": "Tags",
591 | "kernelspec": {
592 | "display_name": "Workspace_JS",
593 | "language": "python",
594 | "name": "python3"
595 | },
596 | "language_info": {
597 | "codemirror_mode": {
598 | "name": "ipython",
599 | "version": 3
600 | },
601 | "file_extension": ".py",
602 | "mimetype": "text/x-python",
603 | "name": "python",
604 | "nbconvert_exporter": "python",
605 | "pygments_lexer": "ipython3",
606 | "version": "3.9.7"
607 | },
608 | "vscode": {
609 | "interpreter": {
610 | "hash": "a812027cb36d52afc6bf34b1f842ed1960d479f5dea7272b4a52eb53764f32d8"
611 | }
612 | }
613 | },
614 | "nbformat": 4,
615 | "nbformat_minor": 2
616 | }
617 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/12-Doubly-Robust-Estimation.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "metadata": {},
7 | "source": [
8 | "# 12 - Doubly Robust Estimation\n",
9 | "\n",
10 | "## 한 곳에만 모든 걸 투자하지 마세요\n",
11 | "\n",
12 | "앞서 선형회귀와 경향 점수(propensity score)로 가중치 방식을 통해 $E[Y|T=1] - E[Y|T=0] | X$ 를 추정하는 방법을 배웠습니다. 그렇다면 언제, 어떤 것을 써야할까요? 고민된다면 둘 다 쓰세요! Doubly Robust Estimation (이중강건추정) 방법은 어느 둘 중 하나에 의존할 필요가 없도록 경향 점수와 선형회귀방법을 결합했습니다.\n",
13 | "\n",
14 | "사고방식 실험을 통해 어떻게 작동하는지 알아봅시다. 사고방식 실험은 미국 고등학교 학생들을 무작위 추출하여 성장 사고방식의 효과를 알아보기 위한 연구입니다. 실험에서 학생들은 성장 사고방식을 심어주는 세미나에 초청됩니다. 그리고 학생들의 대학재학 기간 학업 능력을 추적하여 점수로 매깁니다. 이 점수는 성취점수로 취합되여 표준화됩니다. 이 실험의 실제 데이터는 학생들의 개인정보이므로 공개되지 않습니다. 대신 [Athey and Wager](https://arxiv.org/pdf/1902.07409.pdf)에서 제공한 실제 데이터와 똑같은 통계 요약치를 가지는 모의실험 데이터를 가지고 진행하겠습니다."
15 | ]
16 | },
17 | {
18 | "cell_type": "code",
19 | "execution_count": 1,
20 | "metadata": {
21 | "tags": [
22 | "hide-input"
23 | ]
24 | },
25 | "outputs": [],
26 | "source": [
27 | "import warnings\n",
28 | "warnings.filterwarnings('ignore')\n",
29 | "\n",
30 | "import pandas as pd\n",
31 | "import numpy as np\n",
32 | "from matplotlib import style\n",
33 | "from matplotlib import pyplot as plt\n",
34 | "import seaborn as sns\n",
35 | "\n",
36 | "from sklearn.linear_model import LogisticRegression, LinearRegression\n",
37 | "\n",
38 | "%matplotlib inline\n",
39 | "\n",
40 | "style.use(\"fivethirtyeight\")\n",
41 | "pd.set_option(\"display.max_columns\", 6)"
42 | ]
43 | },
44 | {
45 | "cell_type": "code",
46 | "execution_count": 2,
47 | "metadata": {
48 | "tags": [
49 | "hide-input"
50 | ]
51 | },
52 | "outputs": [
53 | {
54 | "data": {
55 | "text/html": [
56 | "\n",
57 | "\n",
70 | "
\n",
71 | " \n",
72 | " \n",
73 | " \n",
74 | " schoolid \n",
75 | " intervention \n",
76 | " achievement_score \n",
77 | " ... \n",
78 | " school_ethnic_minority \n",
79 | " school_poverty \n",
80 | " school_size \n",
81 | " \n",
82 | " \n",
83 | " \n",
84 | " \n",
85 | " 259 \n",
86 | " 73 \n",
87 | " 1 \n",
88 | " 1.480828 \n",
89 | " ... \n",
90 | " -0.515202 \n",
91 | " -0.169849 \n",
92 | " 0.173954 \n",
93 | " \n",
94 | " \n",
95 | " 3435 \n",
96 | " 76 \n",
97 | " 0 \n",
98 | " -0.987277 \n",
99 | " ... \n",
100 | " -1.310927 \n",
101 | " 0.224077 \n",
102 | " -0.426757 \n",
103 | " \n",
104 | " \n",
105 | " 9963 \n",
106 | " 4 \n",
107 | " 0 \n",
108 | " -0.152340 \n",
109 | " ... \n",
110 | " 0.875012 \n",
111 | " -0.724801 \n",
112 | " 0.761781 \n",
113 | " \n",
114 | " \n",
115 | " 4488 \n",
116 | " 67 \n",
117 | " 0 \n",
118 | " 0.358336 \n",
119 | " ... \n",
120 | " 0.315755 \n",
121 | " 0.054586 \n",
122 | " 1.862187 \n",
123 | " \n",
124 | " \n",
125 | " 2637 \n",
126 | " 16 \n",
127 | " 1 \n",
128 | " 1.360920 \n",
129 | " ... \n",
130 | " -0.033161 \n",
131 | " -0.982274 \n",
132 | " 1.591641 \n",
133 | " \n",
134 | " \n",
135 | "
\n",
136 | "
5 rows × 13 columns
\n",
137 | "
"
138 | ],
139 | "text/plain": [
140 | " schoolid intervention achievement_score ... school_ethnic_minority \\\n",
141 | "259 73 1 1.480828 ... -0.515202 \n",
142 | "3435 76 0 -0.987277 ... -1.310927 \n",
143 | "9963 4 0 -0.152340 ... 0.875012 \n",
144 | "4488 67 0 0.358336 ... 0.315755 \n",
145 | "2637 16 1 1.360920 ... -0.033161 \n",
146 | "\n",
147 | " school_poverty school_size \n",
148 | "259 -0.169849 0.173954 \n",
149 | "3435 0.224077 -0.426757 \n",
150 | "9963 -0.724801 0.761781 \n",
151 | "4488 0.054586 1.862187 \n",
152 | "2637 -0.982274 1.591641 \n",
153 | "\n",
154 | "[5 rows x 13 columns]"
155 | ]
156 | },
157 | "execution_count": 2,
158 | "metadata": {},
159 | "output_type": "execute_result"
160 | }
161 | ],
162 | "source": [
163 | "data = pd.read_csv(\"./data/learning_mindset.csv\")\n",
164 | "data.sample(5, random_state=5)"
165 | ]
166 | },
167 | {
168 | "cell_type": "markdown",
169 | "metadata": {},
170 | "source": [
171 | "실험이 무작위적으로 진행됐지만 교란 변수 (confounding)이 없는 사례처럼은 보이지 않습니다. 한 가지 이유는 처치 변수 (treatment)가 학생들의 세미나 초청권 수령이기 때문입니다. 그래서 참여햘 기회는 무작위이지만 참석 자체는 그렇지 않습니다(초청 받았지만 참석하지 않는 사례들도 곧 다뤄보도록 하겠습니다). 그 증거로 학생들의 성공 기대감과 세미나 참석이 연관성 들 수 있습니다. 높은 기대치를 스스로 되새기는 학생들이 성장 사고방식 세미나에 참석했을 확률이 높을 것 같습니다. "
172 | ]
173 | },
174 | {
175 | "cell_type": "code",
176 | "execution_count": 3,
177 | "metadata": {
178 | "tags": [
179 | "hide-input"
180 | ]
181 | },
182 | "outputs": [
183 | {
184 | "data": {
185 | "text/plain": [
186 | "success_expect\n",
187 | "1 0.271739\n",
188 | "2 0.265957\n",
189 | "3 0.294118\n",
190 | "4 0.271617\n",
191 | "5 0.311070\n",
192 | "6 0.354287\n",
193 | "7 0.362319\n",
194 | "Name: intervention, dtype: float64"
195 | ]
196 | },
197 | "execution_count": 3,
198 | "metadata": {},
199 | "output_type": "execute_result"
200 | }
201 | ],
202 | "source": [
203 | "data.groupby(\"success_expect\")[\"intervention\"].mean()"
204 | ]
205 | },
206 | {
207 | "cell_type": "markdown",
208 | "metadata": {},
209 | "source": [
210 | "우리가 알고 있는 것을 토대로 우리는 이것을 해결하기 위해 선형회귀방법이나 로지스틱 회귀분석을 통한 경향 점수 추정을 적용할 수 있습니다. 하기 전에 범주형 변수들을 더미 (dummy) 처리해야합니다. "
211 | ]
212 | },
213 | {
214 | "cell_type": "code",
215 | "execution_count": 4,
216 | "metadata": {
217 | "tags": [
218 | "hide-input"
219 | ]
220 | },
221 | "outputs": [
222 | {
223 | "name": "stdout",
224 | "output_type": "stream",
225 | "text": [
226 | "(10391, 32)\n"
227 | ]
228 | }
229 | ],
230 | "source": [
231 | "categ = [\"ethnicity\", \"gender\", \"school_urbanicity\"]\n",
232 | "cont = [\"school_mindset\", \"school_achievement\", \"school_ethnic_minority\", \"school_poverty\", \"school_size\"]\n",
233 | "\n",
234 | "data_with_categ = pd.concat([\n",
235 | " data.drop(columns=categ), # dataset without the categorical features\n",
236 | " pd.get_dummies(data[categ], columns=categ, drop_first=False) # categorical features converted to dummies\n",
237 | "], axis=1)\n",
238 | "\n",
239 | "print(data_with_categ.shape)"
240 | ]
241 | },
242 | {
243 | "cell_type": "markdown",
244 | "metadata": {},
245 | "source": [
246 | "이제 doubly robust estimation을 어떻게 작동하는지 이해할 준비가 됐습니다. \n",
247 | "\n",
248 | "## Doubly Robust Estimation\n",
249 | "\n",
250 | "\n",
251 | "\n",
252 | "추정값을 바로 유도하기보단 먼저 이게 얼마나 멋진지 먼저 보여드리겠습니다.\n",
253 | "\n",
254 | "$\n",
255 | "\\hat{ATE} = \\frac{1}{N}\\sum \\bigg( \\dfrac{T_i(Y_i - \\hat{\\mu_1}(X_i))}{\\hat{P}(X_i)} + \\hat{\\mu_1}(X_i) \\bigg) - \\frac{1}{N}\\sum \\bigg( \\dfrac{(1-T_i)(Y_i - \\hat{\\mu_0}(X_i))}{1-\\hat{P}(X_i)} + \\hat{\\mu_0}(X_i) \\bigg)\n",
256 | "$\n",
257 | "\n",
258 | "여기서 $\\hat{P}(x)$는 경향 점수(예를 들면, 로지스틱 회귀분석을 사용해서 얻은 점수)입니다. $\\hat{\\mu_1}(x)$은 $E[Y|X, T=1]$ 추정치(예를 들면, 선형 회귀분석으로 얻은 예측값)이고 그리고 $\\hat{\\mu_0}(x)$은 $E[Y|X, T=0]$의 추정치입니다. 이미 추측했겠지만 doubly robust estimator의 첫번째 항은 $E[Y_1]$를 추정하고 두번째 항은 $E[Y_0]$을 추정합니다. 두번째 항도 동일한 방식으로 유추가 가능하니 첫번째 항에 대해서 자세히 알아보도록 합시다.\n",
259 | "\n",
260 | "처음 봤을 때, 이 공식이 어려워보입니다. 그러나 쫄지마세요. 뒤에서 매우 단순하다는 것을 보여줍니다. 먼저 코드로 어떻게 이 추정량을 작성하는지 보이겠습니다. 수식보다 코드로 이해하는데 더 친숙한 사람들이 있기 때문이죠. 실제로 이 추정량이 계산되는지 알아보죠, 갈까요?"
261 | ]
262 | },
263 | {
264 | "cell_type": "code",
265 | "execution_count": 5,
266 | "metadata": {
267 | "tags": [
268 | "hide-input"
269 | ]
270 | },
271 | "outputs": [],
272 | "source": [
273 | "def doubly_robust(df, X, T, Y):\n",
274 | " ps = LogisticRegression(C=1e6, max_iter=1000).fit(df[X], df[T]).predict_proba(df[X])[:, 1]\n",
275 | " mu0 = LinearRegression().fit(df.query(f\"{T}==0\")[X], df.query(f\"{T}==0\")[Y]).predict(df[X])\n",
276 | " mu1 = LinearRegression().fit(df.query(f\"{T}==1\")[X], df.query(f\"{T}==1\")[Y]).predict(df[X])\n",
277 | " return (\n",
278 | " np.mean(df[T]*(df[Y] - mu1)/ps + mu1) -\n",
279 | " np.mean((1-df[T])*(df[Y] - mu0)/(1-ps) + mu0)\n",
280 | " )"
281 | ]
282 | },
283 | {
284 | "cell_type": "code",
285 | "execution_count": 6,
286 | "metadata": {
287 | "tags": [
288 | "hide-input"
289 | ]
290 | },
291 | "outputs": [
292 | {
293 | "data": {
294 | "text/plain": [
295 | "0.38822197203025405"
296 | ]
297 | },
298 | "execution_count": 6,
299 | "metadata": {},
300 | "output_type": "execute_result"
301 | }
302 | ],
303 | "source": [
304 | "T = 'intervention'\n",
305 | "Y = 'achievement_score'\n",
306 | "X = data_with_categ.columns.drop(['schoolid', T, Y])\n",
307 | "\n",
308 | "doubly_robust(data_with_categ, X, T, Y)"
309 | ]
310 | },
311 | {
312 | "cell_type": "markdown",
313 | "metadata": {},
314 | "source": [
315 | "Doubly robust estimator은 세미나에 참석한 학생들이 참석증을 받지 못한 학생들에 비해 성취 점수가 0.388 높다고 기대합니다. 신뢰구간을 위해서 bootstrap 방법을 할 수 있습니다."
316 | ]
317 | },
318 | {
319 | "cell_type": "code",
320 | "execution_count": 7,
321 | "metadata": {
322 | "scrolled": false,
323 | "tags": [
324 | "hide-input"
325 | ]
326 | },
327 | "outputs": [],
328 | "source": [
329 | "from joblib import Parallel, delayed # for parallel processing\n",
330 | "\n",
331 | "np.random.seed(88)\n",
332 | "# run 1000 bootstrap samples\n",
333 | "bootstrap_sample = 1000\n",
334 | "ates = Parallel(n_jobs=4)(delayed(doubly_robust)(data_with_categ.sample(frac=1, replace=True), X, T, Y)\n",
335 | " for _ in range(bootstrap_sample))\n",
336 | "ates = np.array(ates)"
337 | ]
338 | },
339 | {
340 | "cell_type": "code",
341 | "execution_count": 8,
342 | "metadata": {
343 | "tags": [
344 | "hide-input"
345 | ]
346 | },
347 | "outputs": [
348 | {
349 | "name": "stdout",
350 | "output_type": "stream",
351 | "text": [
352 | "ATE 95% CI: (0.35365379802081925, 0.41978432347111305)\n"
353 | ]
354 | }
355 | ],
356 | "source": [
357 | "print(f\"ATE 95% CI:\", (np.percentile(ates, 2.5), np.percentile(ates, 97.5)))"
358 | ]
359 | },
360 | {
361 | "cell_type": "code",
362 | "execution_count": 9,
363 | "metadata": {
364 | "tags": [
365 | "hide-input"
366 | ]
367 | },
368 | "outputs": [
369 | {
370 | "data": {
371 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAEeCAYAAADFHWEmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAA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JKD23a252/ftTOeyvrWK/f+Nyybm+ffij7YrHofzNr7aO+ijiOL16rOkdZ/eO+pnvpMPLOUdZzHJsY1DCgpyb+pmmq6fT7/UTiOFYURf18FT80c30jcc5t/OfPaC55gJbOU1Z/Nj2ZTPr+pDzP+8cv5Vxl9XNW1pv1/FDxS3luWbe3T79drm+fVVVtvJd//0sP0jlHWX0Y+aZY339z6ROQc5T1HMcmakgDemribxAEj8bp+w1DevghD02MHZNzlXW5XCrLMs1mM3Vdp6Zpds7Jek3nKKt/zyRJlGXZxsTYSzqlrE/puk7L5VJ5nitJEnVd1x+wL+kcZfUnGNtNWW3bXnR+2TnKeg6vej8kAAD2uXwkAgAgAgkAMBIEEgBgFAgkAMAoEEgAgFEgkAAAo0AgAQBGgUACAIwCgQQAGIX/B21058xQDbrEAAAAAElFTkSuQmCC",
372 | "text/plain": [
373 | ""
374 | ]
375 | },
376 | "metadata": {},
377 | "output_type": "display_data"
378 | }
379 | ],
380 | "source": [
381 | "sns.distplot(ates, kde=False)\n",
382 | "plt.vlines(np.percentile(ates, 2.5), 0, 20, linestyles=\"dotted\")\n",
383 | "plt.vlines(np.percentile(ates, 97.5), 0, 20, linestyles=\"dotted\", label=\"95% CI\")\n",
384 | "plt.title(\"ATE Bootstrap Distribution\")\n",
385 | "plt.legend();"
386 | ]
387 | },
388 | {
389 | "cell_type": "markdown",
390 | "metadata": {},
391 | "source": [
392 | "이제 doubly robust estimator 맛을 봤으니 이게 왜 대단한지 보죠. 먼저, $\\hat{P}(x)$ 또는 $\\hat{\\mu}(x)$ 중 하나만 잘 추정한다면 잘 작동하기 때문에 doubly robust 하다고 부릅니다. $E[Y_1]$ 를 추정하는 첫번째 항을 가지고 살펴보도록 하겠습니다. \n",
393 | "\n",
394 | "$\n",
395 | "\\hat{E}[Y_1] = \\frac{1}{N}\\sum \\bigg( \\dfrac{T_i(Y_i - \\hat{\\mu_1}(X_i))}{\\hat{P}(X_i)} + \\hat{\\mu_1}(X_i) \\bigg)\n",
396 | "$\n",
397 | "\n",
398 | "$\\hat{\\mu_1}(x)$ 이 정확하게 추정되었다고 가정해봅시다. 경향 점수 모델이 틀렸다고 해도 걱정할 필요없습니다. 왜냐하면 $\\hat{\\mu_1}(x)$ 정확하다면 $E[T_i(Y_i - \\hat{\\mu_1}(X_i))]=0$ 입니다. $T_i$ 가 곱해져서 처치된 값들만 선택하고 $\\hat{\\mu_1}$ 과의 잔차는 정의상 $0$이 됩니다. 그렇게 되면 추정량은 $\\hat{\\mu_1}(X_i)$ 에만 의존하게 되는데 가정에 의해 $\\hat{\\mu_1}(X_i)$ 은 $E[Y_1]$ 을 정확하게 추정하고 있습니다. 따라서, 교정에 의해 $\\hat{\\mu_1}(X_i)$ 경향 점수 모델을 싹 지워버립니다. 같은 방식으로 $E[Y_0]$ 의 추정량도 이해할 수 있습니다. \n",
399 | "\n",
400 | "글이 아니라 코드를 통해서 보여드릴게요! 다음 추정량에서는 경향 점수를 추정하는 로지스틱 회귀분석을 $0.1$ 에서 $0.9$ 의 값을 갖는 무작위 균일분포의 난수로 대체합니다 (아주 작은 가중치를 줘서 경향 점수 변동이 없어지지 않도록 합니다). 이 난수들은 무작위이기 때문에 경향 점수 모델은 절대 좋다고 할 수 없습니다. 하지만 doubly robust estimator는 여전히 로지스틱 모형으로 경향 점수를 추정했을 때와 매우 유사한 추정치를 갖습니다.\n"
401 | ]
402 | },
403 | {
404 | "cell_type": "code",
405 | "execution_count": 10,
406 | "metadata": {
407 | "tags": [
408 | "hide-input"
409 | ]
410 | },
411 | "outputs": [],
412 | "source": [
413 | "from sklearn.linear_model import LogisticRegression, LinearRegression\n",
414 | "\n",
415 | "def doubly_robust_wrong_ps(df, X, T, Y):\n",
416 | " # wrong PS model\n",
417 | " np.random.seed(654)\n",
418 | " ps = np.random.uniform(0.1, 0.9, df.shape[0])\n",
419 | " mu0 = LinearRegression().fit(df.query(f\"{T}==0\")[X], df.query(f\"{T}==0\")[Y]).predict(df[X])\n",
420 | " mu1 = LinearRegression().fit(df.query(f\"{T}==1\")[X], df.query(f\"{T}==1\")[Y]).predict(df[X])\n",
421 | " return (\n",
422 | " np.mean(df[T]*(df[Y] - mu1)/ps + mu1) -\n",
423 | " np.mean((1-df[T])*(df[Y] - mu0)/(1-ps) + mu0)\n",
424 | " )"
425 | ]
426 | },
427 | {
428 | "cell_type": "code",
429 | "execution_count": 11,
430 | "metadata": {
431 | "tags": [
432 | "hide-input"
433 | ]
434 | },
435 | "outputs": [
436 | {
437 | "data": {
438 | "text/plain": [
439 | "0.3796984428841887"
440 | ]
441 | },
442 | "execution_count": 11,
443 | "metadata": {},
444 | "output_type": "execute_result"
445 | }
446 | ],
447 | "source": [
448 | "doubly_robust_wrong_ps(data_with_categ, X, T, Y)"
449 | ]
450 | },
451 | {
452 | "cell_type": "markdown",
453 | "metadata": {},
454 | "source": [
455 | "Bootstrap 방법을 사용한다면 로지스틱 방법보다 추정치의 분산이 약간 큰 것을 알 수 있습니다."
456 | ]
457 | },
458 | {
459 | "cell_type": "code",
460 | "execution_count": 12,
461 | "metadata": {
462 | "tags": [
463 | "hide-input"
464 | ]
465 | },
466 | "outputs": [],
467 | "source": [
468 | "np.random.seed(88)\n",
469 | "parallel_fn = delayed(doubly_robust_wrong_ps)\n",
470 | "wrong_ps = Parallel(n_jobs=4)(parallel_fn(data_with_categ.sample(frac=1, replace=True), X, T, Y)\n",
471 | " for _ in range(bootstrap_sample))\n",
472 | "wrong_ps = np.array(wrong_ps)"
473 | ]
474 | },
475 | {
476 | "cell_type": "code",
477 | "execution_count": 13,
478 | "metadata": {
479 | "tags": [
480 | "hide-input"
481 | ]
482 | },
483 | "outputs": [
484 | {
485 | "name": "stdout",
486 | "output_type": "stream",
487 | "text": [
488 | "Original ATE 95% CI: (0.35365379802081925, 0.41978432347111305)\n",
489 | "Wrong PS ATE 95% CI: (0.3386340898920725, 0.4330454015305953)\n"
490 | ]
491 | }
492 | ],
493 | "source": [
494 | "print(f\"Original ATE 95% CI:\", (np.percentile(ates, 2.5), np.percentile(ates, 97.5)))\n",
495 | "\n",
496 | "print(f\"Wrong PS ATE 95% CI:\", (np.percentile(wrong_ps, 2.5), np.percentile(wrong_ps, 97.5)))"
497 | ]
498 | },
499 | {
500 | "cell_type": "markdown",
501 | "metadata": {},
502 | "source": [
503 | "앞에서 보셨다시피 경향 점수를 망가뜨려서 약간 다르지만 큰 차이는 아닌 ATE 값들이 나왔습니다. 이 경우는 경향 점수가 잘못되고 평균 추정이 정확했습니다. 다른 상황에서는 어떨까요? \n",
504 | "첫번째 항을 다시 살펴보고 항들의 순서를 바꾸어보겠습니다. \n",
505 | "\n",
506 | "$\n",
507 | "\\hat{E}[Y_1] = \\frac{1}{N}\\sum \\bigg( \\dfrac{T_i(Y_i - \\hat{\\mu_1}(X_i))}{\\hat{P}(X_i)} + \\hat{\\mu_1}(X_i) \\bigg)\n",
508 | "$\n",
509 | "\n",
510 | "$\n",
511 | "\\hat{E}[Y_1] = \\frac{1}{N}\\sum \\bigg( \\dfrac{T_iY_i}{\\hat{P}(X_i)} - \\dfrac{T_i\\hat{\\mu_1}(X_i)}{\\hat{P}(X_i)} + \\hat{\\mu_1}(X_i) \\bigg)\n",
512 | "$\n",
513 | "\n",
514 | "$\n",
515 | "\\hat{E}[Y_1] = \\frac{1}{N}\\sum \\bigg( \\dfrac{T_iY_i}{\\hat{P}(X_i)} - \\bigg(\\dfrac{T_i}{\\hat{P}(X_i)} - 1\\bigg) \\hat{\\mu_1}(X_i) \\bigg)\n",
516 | "$\n",
517 | "\n",
518 | "$\n",
519 | "\\hat{E}[Y_1] = \\frac{1}{N}\\sum \\bigg( \\dfrac{T_iY_i}{\\hat{P}(X_i)} - \\bigg(\\dfrac{T_i - \\hat{P}(X_i)}{\\hat{P}(X_i)}\\bigg) \\hat{\\mu_1}(X_i) \\bigg)\n",
520 | "$\n",
521 | "\n",
522 | "이제 경향 점수 $\\hat{P}(X_i)$ 가 정확하다고 가정해봅시다. 이 경우에는 $E[T_i - \\hat{P}(X_i)]=0$ 가 돼서 $\\hat{\\mu_1}(X_i)$ 와 관련된 항들을 지워버립니다. 이것이 doubly robust estimator 가 가정에 의해서 정확한 경향 점수 가중치 추정량 $\\frac{T_iY_i}{\\hat{P}(X_i)}$ 에만 의존하도록 만듭니다. 따라서 $\\hat{\\mu_1}(X_i)$ 가 틀렸다고 하더라도 경향 점수가 정확하기 때문에 추정량은 정확하게 됩니다. \n",
523 | "\n",
524 | "만약 수식보다 코드를 더 믿는다면 여기서 실제로 보이겠습니다. 아래 코드에서 회귀분석모델을 정규분포난수로 대체합니다. 여지 없이 $\\hat{\\mu}(X_i)$ 는 **틀렸습니다**. 그러나 여전히 doubly robust estimation는 앞서 본 약 0.38과 같은 $\\hat{ATE}$ 를 보입니다. "
525 | ]
526 | },
527 | {
528 | "cell_type": "code",
529 | "execution_count": 14,
530 | "metadata": {
531 | "tags": [
532 | "hide-input"
533 | ]
534 | },
535 | "outputs": [],
536 | "source": [
537 | "from sklearn.linear_model import LogisticRegression, LinearRegression\n",
538 | "\n",
539 | "def doubly_robust_wrong_model(df, X, T, Y):\n",
540 | " np.random.seed(654)\n",
541 | " ps = LogisticRegression(C=1e6, max_iter=1000).fit(df[X], df[T]).predict_proba(df[X])[:, 1]\n",
542 | " \n",
543 | " # wrong mu(x) model\n",
544 | " mu0 = np.random.normal(0, 1, df.shape[0])\n",
545 | " mu1 = np.random.normal(0, 1, df.shape[0])\n",
546 | " return (\n",
547 | " np.mean(df[T]*(df[Y] - mu1)/ps + mu1) -\n",
548 | " np.mean((1-df[T])*(df[Y] - mu0)/(1-ps) + mu0)\n",
549 | " )"
550 | ]
551 | },
552 | {
553 | "cell_type": "code",
554 | "execution_count": 15,
555 | "metadata": {
556 | "tags": [
557 | "hide-input"
558 | ]
559 | },
560 | "outputs": [
561 | {
562 | "data": {
563 | "text/plain": [
564 | "0.3981405305433191"
565 | ]
566 | },
567 | "execution_count": 15,
568 | "metadata": {},
569 | "output_type": "execute_result"
570 | }
571 | ],
572 | "source": [
573 | "doubly_robust_wrong_model(data_with_categ, X, T, Y)"
574 | ]
575 | },
576 | {
577 | "cell_type": "markdown",
578 | "metadata": {},
579 | "source": [
580 | "또 bootstrap을 통해 추정치의 분산은 약간 높아지는 것을 확인할 수 있었습니다."
581 | ]
582 | },
583 | {
584 | "cell_type": "code",
585 | "execution_count": 16,
586 | "metadata": {
587 | "tags": [
588 | "hide-input"
589 | ]
590 | },
591 | "outputs": [],
592 | "source": [
593 | "np.random.seed(88)\n",
594 | "parallel_fn = delayed(doubly_robust_wrong_model)\n",
595 | "wrong_mux = Parallel(n_jobs=4)(parallel_fn(data_with_categ.sample(frac=1, replace=True), X, T, Y)\n",
596 | " for _ in range(bootstrap_sample))\n",
597 | "wrong_mux = np.array(wrong_mux)"
598 | ]
599 | },
600 | {
601 | "cell_type": "code",
602 | "execution_count": 17,
603 | "metadata": {
604 | "tags": [
605 | "hide-input"
606 | ]
607 | },
608 | "outputs": [
609 | {
610 | "name": "stdout",
611 | "output_type": "stream",
612 | "text": [
613 | "Original ATE 95% CI: (0.35365379802081925, 0.41978432347111305)\n",
614 | "Wrong Mu ATE 95% CI: (0.3387086426185005, 0.41978432347111305)\n"
615 | ]
616 | }
617 | ],
618 | "source": [
619 | "print(f\"Original ATE 95% CI:\", (np.percentile(ates, 2.5), np.percentile(ates, 97.5)))\n",
620 | "print(f\"Wrong Mu ATE 95% CI:\", (np.percentile(wrong_mux, 2.5), np.percentile(ates, 97.5)))"
621 | ]
622 | },
623 | {
624 | "attachments": {},
625 | "cell_type": "markdown",
626 | "metadata": {},
627 | "source": [
628 | "다시 한번 말하면 조건부 기댓값 모델만 망가뜨렸을 때 약간 다른 ATE 값이 나왔습니다. 나는 doubly robust estimation의 강력함을 저자들에게 확신시켰다고 생각합니다. 인과추론에서 doubly robust estimation의 마법은 일어납니다. 왜냐하면 인과 추정치의 편향을 없애기 위해 두 가지 방법이 있기 때문입니다. 하나는 처치 방식을 잘 모델링하는 것이고 다른 하나는 종속변수를 잘 모델링하는 것입니다. 만약 둘 중에 하나가 정확하다면 진행해도 좋습니다.\n",
629 | "\n",
630 | "실제로 사용할 때 한 가지 주의할 점은 실제로 둘 중에 하나를 정화하게 모델링하는 것은 매우 어렵다는 것입니다. 실제로 경향 점수나 종속변수 모델링이 100% 정확하지 않는 경우가 결국에는 더 많습니다. 둘 다 다양한 방식으로 틀리게 됩니다. 이렇게 되면 단일 모델이 나을지 doubly robust estimation이 나을지 정확하게 알 수 없습니다 [\\[1\\]](https://www.stat.cmu.edu/~ryantibs/journalclub/kang_2007.pdf) [\\[2\\]](https://arxiv.org/pdf/0804.2969.pdf) [\\[3\\]](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2798744/). 저같은 경우에 적어도 정확할 수 있는 두 개의 가능성이 있기 때문에 둘 다 사용합니다. \n",
631 | "\n",
632 | "## Key Ideas\n",
633 | "\n",
634 | "이 장에서는 doubly robust estimator 를 만드는 선형회귀와 경향 점수를 결합하는 방식을 보았습니다. 이 추정량은 하나의 모델만 정확한 것을 요구하기 때문에 그런 이름이 붙었습니다. 만약 경향 점수 모델이 맞다면 종속변수 모델이 틀렸더라도 우리는 인과 효과를 추정할 수 있습니다. 반대로 종속변수 모델이 맞다면 경향 점수 모델이 틀리더라도 인과 효과를 추정할 수 있습니다. \n",
635 | "\n",
636 | "## References\n",
637 | "\n",
638 | "이 책을 쓰기 위해 Joshua Angrist, Alberto Abadie, Christopher Walters의 대단한 계량 경제학 수업 자료를 많이 참고했습니다. 해당 자료에 있는 대부분의 아이디어는 전미경제학회(American Economic Association)의 수업에서 가져왔어요. 이렇게 좋은 참고자료를 보는 것이 2020년의 힘든 한 해를 지탱하게 만들어준 원동력이었다고 생각해요.\n",
639 | "\n",
640 | "* [Cross-Section Econometrics](https://www.aeaweb.org/conference/cont-ed/2017-webcasts)\n",
641 | "* [Mastering Mostly Harmless Econometrics](https://www.aeaweb.org/conference/cont-ed/2020-webcasts)\n",
642 | "\n",
643 | "또한, Angrist의 정말 좋은 책들을 참고자료에 넣고 싶어요. 해당 저자가 쓴 책들은 계량경제학(Econometrics) 또는 '메트릭스(Metrics, 계량적 분석)'가 매우 유용할 뿐만 아니라 매우 흥미롭다는 걸 알려주었어요.\n",
644 | "\n",
645 | "* [Mostly Harmless Econometrics](https://www.mostlyharmlesseconometrics.com/)\n",
646 | "* [Mastering ‘Metrics](https://www.masteringmetrics.com/)\n",
647 | "\n",
648 | "마지막으로 참고한 자료는 Miguel Hernan과 Jamie Robins의 책입니다. 이 책들은 제가 대답해야 했던 까다로운 인과적인 질문에서 신뢰할 수 있는 동반자 같은 존재였어요.\n",
649 | "\n",
650 | "* [Causal Inference Book](https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/)\n",
651 | "\n",
652 | "해당 챕터에 사용된 데이터는 Susan Athey과 Stefan Wager [Estimating Treatment Effects with Causal Forests: An Application](https://arxiv.org/pdf/1902.07409.pdf)에서 제공하고 있습니다.\n",
653 | "\n",
654 | "## Contribute\n",
655 | "\n",
656 | "Causal Inference for the Brave and True는 인과추론, 통계학에 대한 오픈소스 자료입니다. 이 자료는 금전적으로나 지적으로 접근이 가능할 수 있도록 하는 것이 목표입니다. 그리고, 이 책은 Python 기반의 무료 소프트웨어만 사용해요. 여러분들께서 이 자료가 가치 있다고 생각하시고, 금전적으로 지원을 원하신다면 [Patreon](https://www.patreon.com/causal_inference_for_the_brave_and_true)를 방문해주세요. 만약 여러분이 금전적으로 기여하기가 쉽지 않으시다면, 오타 수정, 수정 제안, 이해하기 난해한 부분에 대한 피드백 제공 등을 통해 도움을 주실 수 있어요. 이 책의 Github 저장소 [이슈 페이지](https://github.com/matheusfacure/python-causality-handbook/issues)를 방문해주세요. 마지막으로 이 자료가 여러분의 마음에 드셨다면 도움이 될 수 있는 다른 사람들과 공유해주시고, 이 책의 [Github 자료에 star](https://github.com/CausalInferenceLab/Causal-Inference-with-Python) 부탁드립니다!"
657 | ]
658 | }
659 | ],
660 | "metadata": {
661 | "celltoolbar": "Tags",
662 | "kernelspec": {
663 | "display_name": "Python 3.7.7 ('crypto')",
664 | "language": "python",
665 | "name": "python3"
666 | },
667 | "language_info": {
668 | "codemirror_mode": {
669 | "name": "ipython",
670 | "version": 3
671 | },
672 | "file_extension": ".py",
673 | "mimetype": "text/x-python",
674 | "name": "python",
675 | "nbconvert_exporter": "python",
676 | "pygments_lexer": "ipython3",
677 | "version": "3.7.7"
678 | },
679 | "vscode": {
680 | "interpreter": {
681 | "hash": "6612ddc8508fe2bfb55c921cc5a3fb1a13f883f137f06750cc87c7c54112973a"
682 | }
683 | }
684 | },
685 | "nbformat": 4,
686 | "nbformat_minor": 2
687 | }
688 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/_config.yml:
--------------------------------------------------------------------------------
1 | # in _config.yml
2 | title: "Python으로 하는 인과추론"
3 | author: Jinsoo Shin
4 |
5 | latex:
6 | latex_documents:
7 | targetname: book.tex
8 |
9 | execute:
10 | execute_notebooks: "off"
11 |
12 | repository:
13 | url: https://github.com/CausalInferenceLab/Causal-Inference-with-Python
14 |
15 |
16 | html:
17 | use_issues_button: true
18 | use_repository_button: true
19 |
20 |
21 | exclude_patterns: [_build, .DS_Store, "**.ipynb_checkpoints"]
22 |
23 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/_toc.yml:
--------------------------------------------------------------------------------
1 | format: jb-book
2 | root: landing-page
3 | parts:
4 | - caption: 인과추론 Part I
5 | chapters:
6 | - file: 01-Introduction-To-Causality.ipynb
7 | - file: 02-Randomised-Experiments.ipynb
8 | - file: 03-Stats-Review-The-Most-Dangerous-Equation.ipynb
9 | - file: 04-Graphical-Causal-Models.ipynb
10 | - file: 05-The-Unreasonable-Effectiveness-of-Linear-Regression.ipynb
11 | - file: 06-Grouped-and-Dummy-Regression.ipynb
12 | - file: 07-Beyond-Confounders.ipynb
13 | - file: 08-Instrumental-Variables.ipynb
14 | - file: 09-Non-Compliance-and-LATE.ipynb
15 | - file: 10-Matching.ipynb
16 | - file: 11-Propensity-Score.ipynb
17 | - file: 12-Doubly-Robust-Estimation.ipynb
18 | - file: 13-Difference-in-Differences.ipynb
19 | - file: 14-Panel-Data-and-Fixed-Effects.ipynb
20 | - file: 15-Synthetic-Control.ipynb
21 | - file: 16-Regression-Discontinuity-Design.ipynb
22 | - caption: 인과추론 Part II
23 | chapters:
24 | - file: 17-Predictive-Models-101.ipynb
25 | - file: 18-Heterogeneous-Treatment-Effects-and-Personalization.ipynb
26 | #- file: 19-Evaluating-Causal-Models.ipynb
27 | #- file: 20-Plug-and-Play-Estimators.ipynb
28 | #- file: 21-Meta-Learners.ipynb
29 | #- file: 22-Debiased-Orthogonal-Machine-Learning.ipynb
30 | #- file: 23-Challenges-with-Effect-Heterogeneity-and-Nonlinearity.ipynb
31 | #- file: 24-The-Diff-in-Diff-Saga.ipynb
32 | #- file: 25-Synthetic-Diff-in-Diff.ipynb
33 | #- caption: Appendix
34 | # chapters:
35 | # - file: Debiasing-with-Orthogonalization.ipynb
36 | # - file: Debiasing-with-Propensity-Score.ipynb
37 | # - file: When-Prediction-Fails.ipynb
38 | # - file: Prediction-Metrics-For-Causal-Models.ipynb
39 | # - file: Conformal-Inference-for-Synthetic-Control.ipynb
40 | #- caption: Contribute
41 | # chapters:
42 | - url: https://www.patreon.com/causal_inference_for_the_brave_and_true
43 | title: Patreon
44 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/drinking.csv:
--------------------------------------------------------------------------------
1 | agecell,all,allfitted,internal,internalfitted,external,externalfitted,alcohol,alcoholfitted,homicide,homicidefitted,suicide,suicidefitted,mva,mvafitted,drugs,drugsfitted,externalother,externalotherfitted
2 | 19.068493,92.8254,91.70615,16.61759,16.73813,76.20782,74.96801,0.63913804,0.7943445,16.316818,16.284573,11.203714,11.5921,35.829327,34.81778,3.8724246,3.448835,8.534373,8.388236
3 | 19.150684,95.10074,91.88372,18.327684,16.920654,76.773056,74.963066,0.6774093,0.8375749,16.859964,16.270697,12.193368,11.593611,35.639256,34.63389,3.2365112,3.4700222,8.655786,8.530174
4 | 19.232876,92.144295,92.049065,18.911053,17.098843,73.23324,74.950226,0.8664426,0.8778347,15.219254,16.262882,11.715812,11.595129,34.20565,34.446735,3.2020707,3.4920695,8.513741,8.662681
5 | 19.31507,88.42776,92.20214,16.10177,17.27268,72.32598,74.92947,0.86730844,0.9151149,16.742825,16.261148,11.27501,11.596655,32.278957,34.2563,3.2806885,3.5149798,8.258285,8.7857275
6 | 19.39726,88.70494,92.34292,17.36352,17.442156,71.341415,74.90076,1.0191631,0.94940656,14.947726,16.26551,10.984314,11.598189,32.650967,34.062588,3.5481975,3.5387552,8.417533,8.899288
7 | 19.479452,90.19179,92.471344,17.872105,17.607254,72.31968,74.86409,1.1713219,0.98070073,15.642815,16.27599,12.166634,11.599731,32.721443,33.86558,3.211689,3.5633986,7.9725456,9.003332
8 | 19.561644,96.22031,92.58739,16.414942,17.767965,79.80537,74.81942,0.8699163,1.0089884,16.263653,16.292604,12.405763,11.601281,36.385197,33.66527,3.8578897,3.5889127,10.287705,9.097831
9 | 19.643835,89.615555,92.69102,15.977087,17.924273,73.638466,74.76675,1.0979514,1.0342605,15.825645,16.31537,10.979514,11.602839,34.187935,33.461647,3.4831562,3.6153,8.670031,9.182756
10 | 19.726027,93.3817,92.782196,17.433271,18.076166,75.948425,74.706024,1.174851,1.0565081,16.789,16.344309,11.900103,11.604405,31.910467,33.254696,4.0551305,3.6425629,10.76315,9.2580805
11 | 19.80822,90.857956,92.86087,18.2854,18.22363,72.572556,74.637245,0.9484129,1.0757217,16.616194,16.379436,11.570638,11.60598,30.576832,33.044415,3.5660326,3.6707044,9.863494,9.323772
12 | 19.890411,95.81015,92.927025,18.6076,18.366652,77.20255,74.56037,1.3291142,1.0918926,17.278484,16.420774,11.468357,11.607562,33.531654,32.830788,4.101267,3.6997268,9.835445,9.379805
13 | 19.972603,94.158066,92.980606,18.43628,18.505219,75.72179,74.47539,1.2164142,1.1050112,16.953773,16.468338,11.631961,11.609152,33.603443,32.613808,3.7632816,3.729633,9.123107,9.426147
14 | 20.054794,92.4646,93.02158,19.634459,18.639317,72.83014,74.38227,1.0273844,1.1150686,17.199177,16.52215,11.263178,11.61075,31.772816,32.393467,3.729025,3.7604258,8.295178,9.46277
15 | 20.136986,98.2456,93.09767,20.88386,18.778563,77.36174,74.319115,0.9527308,1.1226311,17.034826,16.590736,11.928189,11.618317,34.29831,32.186256,3.9252508,3.7940538,9.679745,9.494516
16 | 20.219177,94.9604,93.16124,18.473003,18.913473,76.4874,74.24777,1.3740251,1.1271195,16.297464,16.6657,11.87005,11.625911,33.32011,31.975483,4.2365775,3.828613,9.809012,9.516518
17 | 20.30137,93.38532,93.212234,18.883484,19.044024,74.50184,74.168205,0.9938675,1.1285197,15.940106,16.747074,12.46157,11.633533,32.759403,31.761126,3.4403107,3.8641078,9.250613,9.528728
18 | 20.383562,90.12092,93.25059,18.56782,19.170197,71.5531,74.08039,1.2250932,1.1268175,16.883316,16.834883,11.102407,11.641183,30.589046,31.543165,3.254154,3.9005423,8.9967785,9.531103
19 | 20.465754,92.40623,93.276245,19.36313,19.291971,73.04309,73.984276,0.9969136,1.1219985,17.33096,16.92916,10.889364,11.648862,31.28775,31.32159,4.1793685,3.9379208,8.972222,9.523599
20 | 20.547945,93.354485,93.289154,19.968874,19.409328,73.38561,73.87982,0.960042,1.1140486,16.743132,17.029932,11.482102,11.6565695,30.298925,31.096382,4.3777914,3.976248,9.83083,9.506168
21 | 20.630136,92.22878,93.289246,19.422657,19.522247,72.80612,73.767,0.9615177,1.1029531,15.884273,17.137232,12.345887,11.664306,30.230118,30.867521,3.6537673,4.015528,10.192088,9.478767
22 | 20.712328,92.332245,93.276474,20.377037,19.630705,71.95521,73.64577,1.0015179,1.0886977,17.411003,17.25109,10.978177,11.6720705,30.122578,30.634996,3.6593924,4.055765,9.39886,9.441348
23 | 20.794521,92.66751,93.25076,19.521132,19.734684,73.14638,73.51608,1.1959587,1.0712676,17.9008,17.37153,11.303739,11.679864,29.74465,30.398787,4.3594623,4.096964,9.220456,9.393866
24 | 20.876713,93.3902,93.212074,18.623945,19.834162,74.76625,73.37791,0.96597224,1.0506482,18.160278,17.498592,12.209889,11.687687,30.717916,30.158875,3.9411666,4.139129,9.157417,9.336272
25 | 20.958904,94.26991,93.160324,20.200695,19.92912,74.06922,73.23121,1.2383568,1.0268247,17.143503,17.6323,11.880486,11.6955385,30.41714,29.915245,4.4890437,4.182265,9.48117,9.268521
26 | 20.99999,,93.13445,,19.976597,,73.15786,,1.014913,,17.699154,,11.699464,,29.79343,,4.203832,,9.234646
27 | 21.0,,102.89176,,21.10804,,81.78372,,1.8173605,,17.76202,,13.547069,,34.785976,,4.4421463,,10.353402
28 | 21.041096,105.26835,102.58908,21.937366,21.104536,83.330986,81.48454,2.5193088,1.7885877,18.332817,17.72146,12.402751,13.520511,36.316807,34.590244,4.224687,4.4496655,10.697372,10.321973
29 | 21.123287,101.06651,101.98372,21.121853,21.097532,79.944664,80.88619,1.5919044,1.7310421,17.316814,17.64034,14.83189,13.467395,32.575798,34.198776,4.426271,4.464704,9.978522,10.259112
30 | 21.205479,96.96652,101.412476,19.25328,21.102318,77.71324,80.31016,1.3613431,1.6776136,16.880655,17.563643,12.213193,13.416207,33.022293,33.815987,4.745253,4.4810143,10.268416,10.200633
31 | 21.287672,102.8269,100.87552,21.508316,21.118961,81.31858,79.75656,1.4416807,1.6283239,17.378096,17.49139,14.4557705,13.36696,35.106873,33.441917,4.1691847,4.498604,9.624192,10.146556
32 | 21.369864,100.97943,100.37305,22.366144,21.14752,78.61329,79.225525,1.3271359,1.5831952,17.018566,17.423609,13.583627,13.319661,32.358696,33.07662,4.410775,4.5174794,10.578053,10.096907
33 | 21.452055,101.236946,99.905235,21.232779,21.18806,80.00417,78.71717,1.7205198,1.5422496,17.478916,17.360321,13.803261,13.2743225,32.45526,32.72013,4.8487377,4.5376472,10.284016,10.051706
34 | 21.534246,99.4976,99.47227,21.27055,21.240648,78.22704,78.23162,1.1359962,1.5055093,18.410973,17.30155,12.848509,13.230954,31.533688,32.372505,4.622329,4.5591145,10.341482,10.010981
35 | 21.616438,95.20131,99.07433,22.093296,21.305344,73.10801,77.76899,1.0202943,1.472997,16.599403,17.24732,11.811869,13.189567,30.098682,32.03379,4.8660192,4.581888,9.496586,9.974753
36 | 21.69863,97.25825,98.71162,21.267872,21.382215,75.99038,77.32941,1.6117979,1.444735,18.044275,17.197657,13.3268175,13.15017,30.388288,31.704031,4.4029603,4.6059756,8.963169,9.943048
37 | 21.780823,98.92873,98.384315,19.454931,21.471325,79.47379,76.91299,1.7328279,1.4207466,17.17075,17.152584,14.76842,13.112777,31.742258,31.383278,5.0803366,4.6313834,9.806231,9.915888
38 | 21.863014,102.26221,98.092606,20.515566,21.572742,81.74664,76.51987,1.3019494,1.4010543,17.16206,17.112127,13.926913,13.077396,34.481934,31.071575,4.8132677,4.6581187,10.573407,9.893299
39 | 21.945206,96.833374,97.83669,22.093819,21.686531,74.739555,76.15016,1.1461909,1.3856815,16.718578,17.07631,12.370957,13.04404,31.540012,30.768976,4.2685733,4.6861887,9.446195,9.875306
40 | 22.027397,99.50197,97.61676,21.024887,21.812757,78.47707,75.80401,1.3462263,1.3746514,17.223778,17.045156,12.274417,13.012717,31.834293,30.475529,4.9097667,4.7156005,11.482519,9.861933
41 | 22.109589,96.07229,97.43374,23.40324,21.951653,72.669044,75.48208,1.6263269,1.3679978,17.016933,17.01882,11.622288,12.983537,29.55155,30.191505,4.4029827,4.746397,9.440629,9.853277
42 | 22.19178,95.96821,97.28708,20.624224,22.103125,75.34398,75.18395,1.8279659,1.3657339,16.570908,16.9972,12.597069,12.956413,30.836988,29.916727,4.609653,4.7785506,9.497475,9.849293
43 | 22.273973,98.61067,97.177,23.129915,22.267242,75.48076,74.90976,1.6322316,1.3678838,17.198147,16.980322,12.420884,12.931358,29.857895,29.651249,4.9365053,4.8120685,10.0720625,9.850004
44 | 22.356165,97.95247,97.10369,23.092215,22.444073,74.86025,74.659615,1.5554341,1.3744715,17.109776,16.96821,13.879258,12.908381,28.75559,29.395117,5.1050143,4.846958,9.372488,9.855436
45 | 22.438356,97.41173,97.06736,24.37291,22.633688,73.03882,74.43367,1.6381792,1.3855213,16.701437,16.960892,13.86459,12.887496,27.64927,29.148384,4.4350705,4.883228,9.469475,9.865617
46 | 22.520548,97.509476,97.0682,23.49674,22.836157,74.01273,74.23204,1.5611123,1.4010576,17.532492,16.958393,12.809127,12.868712,28.260136,28.911102,4.523223,4.920884,9.887045,9.88057
47 | 22.60274,95.56239,97.10642,22.817877,23.051548,72.744514,74.05487,1.2431532,1.4211051,16.040686,16.960741,12.15082,12.852041,29.234152,28.683325,5.0127144,4.9599347,10.025429,9.900323
48 | 22.68493,97.02306,97.18223,21.815123,23.279934,75.20794,73.90229,0.883854,1.4456885,16.793226,16.967962,12.856058,12.837497,29.528757,28.4651,5.4236493,5.0003877,10.204496,9.924901
49 | 22.767124,99.37457,97.29582,24.350594,23.521387,75.02398,73.77444,1.2074674,1.4748328,17.226536,16.980082,14.610356,12.8250885,27.44976,28.256483,4.789621,5.042251,10.504967,9.954332
50 | 22.849316,94.31531,97.447426,22.94374,23.77598,71.37157,73.67144,1.3709793,1.5085632,16.69369,16.997128,12.338814,12.814829,26.855064,28.057526,5.564563,5.0855317,9.435563,9.988643
51 | 22.931507,97.397644,97.63723,24.23832,24.043783,73.159325,73.59345,1.7774768,1.5469048,17.774767,17.019129,11.917173,12.806729,27.389301,27.868282,4.9688554,5.130238,10.099299,10.027859
52 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/hospital_treatment.csv:
--------------------------------------------------------------------------------
1 | hospital,treatment,severity,days
2 | 1,1,29.68661809190674,82
3 | 1,1,20.05034002189231,57
4 | 1,1,20.30239881248276,49
5 | 0,0,10.60311785194925,44
6 | 0,0,8.332793071329407,15
7 | 1,1,21.758550579956434,47
8 | 1,1,21.327448392585648,48
9 | 0,0,4.303175222038317,7
10 | 0,1,7.207283266459029,24
11 | 0,1,6.070862178525765,14
12 | 0,0,4.789457939363819,23
13 | 0,0,4.212921227504667,29
14 | 1,1,23.464904341428472,49
15 | 1,1,20.92600219571415,48
16 | 1,1,20.53715556398321,55
17 | 0,0,5.4312073991796685,16
18 | 1,1,14.342576565794099,47
19 | 1,1,21.555786241020208,52
20 | 1,1,15.988342151856092,30
21 | 1,1,11.124161856729355,29
22 | 1,1,19.30868453439712,56
23 | 0,0,-4.030355814517009,0
24 | 1,1,18.43053213846864,52
25 | 1,0,18.459255366409295,47
26 | 1,1,13.496527762740396,29
27 | 1,1,17.05937147227385,44
28 | 1,1,16.716497106468633,51
29 | 1,1,11.631451456633389,26
30 | 1,1,21.59907406097571,41
31 | 0,0,10.990871585259548,40
32 | 0,0,10.662402581085297,41
33 | 1,1,18.7122356433277,49
34 | 1,1,19.34971607037092,53
35 | 1,1,20.851634146711035,50
36 | 1,1,13.974703759301523,33
37 | 0,0,16.738970681321835,45
38 | 1,1,17.35338037885459,55
39 | 1,1,14.435092546669193,37
40 | 1,1,18.702688315989445,48
41 | 0,0,4.277110911803915,27
42 | 0,0,14.507148103884719,51
43 | 1,1,23.653800862521376,51
44 | 0,0,8.567537012901722,29
45 | 0,0,8.78531987243314,26
46 | 0,0,13.569290501083774,53
47 | 1,1,25.62129332283528,60
48 | 1,1,14.530000549011794,35
49 | 0,0,6.883272739837913,36
50 | 1,1,20.097209378373694,48
51 | 1,1,20.762651131416032,54
52 | 1,0,18.33307712322896,63
53 | 0,0,9.850827762530315,43
54 | 1,1,23.32180296971828,68
55 | 1,1,18.6917819575034,42
56 | 1,1,14.932152734747788,36
57 | 0,0,2.956746677935584,22
58 | 1,1,16.01711908876523,45
59 | 1,0,31.067416491153757,67
60 | 1,1,22.568000830990364,54
61 | 0,0,16.565257818798667,58
62 | 1,1,19.0837814111937,49
63 | 1,1,16.519551452099265,38
64 | 0,0,9.393171029539495,31
65 | 0,0,3.882968917283679,13
66 | 1,1,18.27549742570222,54
67 | 0,0,14.264939751887525,49
68 | 0,0,8.621892715657257,19
69 | 0,0,7.891128046822556,35
70 | 1,1,21.57854623631077,59
71 | 1,1,24.912477749048726,68
72 | 0,0,2.3519666762624283,7
73 | 1,1,26.650685824747153,72
74 | 1,1,27.242014029255106,73
75 | 0,0,9.820683378340444,35
76 | 1,1,20.456665254823022,48
77 | 1,1,18.879461912449205,41
78 | 1,1,22.497424230704993,41
79 | 0,0,2.9026514590083883,27
80 | 1,1,24.634592485036222,39
81 | 1,1,16.183497861445662,41
82 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/beyond-conf/cop-ex1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/beyond-conf/cop-ex1.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/beyond-conf/cop-ex2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/beyond-conf/cop-ex2.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/beyond-conf/cop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/beyond-conf/cop.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/beyond-conf/selection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/beyond-conf/selection.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/beyond-conf/shocked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/beyond-conf/shocked.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/beyond-conf/y-pred.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/beyond-conf/y-pred.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/brave-and-true.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/brave-and-true.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-graph/both_crap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-graph/both_crap.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-graph/selection_bias.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-graph/selection_bias.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-graph/three_bias.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-graph/three_bias.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-model/customers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-model/customers.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-model/economists.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-model/economists.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-model/elast-partition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-model/elast-partition.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-model/elast-split.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-model/elast-split.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-model/elasticity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-model/elasticity.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-model/linear-fix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-model/linear-fix.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-model/y-partition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-model/y-partition.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/causal-model/y-split.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/causal-model/y-split.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/curse-of-dimensionality.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/curse-of-dimensionality.jpg
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debias-ps/again.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debias-ps/again.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debias-ps/fear-no-man.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debias-ps/fear-no-man.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debias-ps/ps-experiment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debias-ps/ps-experiment.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debiased-ml/avengers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debiased-ml/avengers.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debiased-ml/cf-pred.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debiased-ml/cf-pred.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debiased-ml/cross-prediction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debiased-ml/cross-prediction.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debiased-ml/diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debiased-ml/diagram.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debiased-ml/drown-ols.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debiased-ml/drown-ols.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debiased-ml/linear-aprox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debiased-ml/linear-aprox.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debiased-ml/ml-problem.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debiased-ml/ml-problem.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debiased-ml/more-metrics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debiased-ml/more-metrics.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debiased-ml/non-linear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debiased-ml/non-linear.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/debiased-ml/non-sci.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/debiased-ml/non-sci.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/did-saga/awful.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/did-saga/awful.jpeg
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/did-saga/death.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/did-saga/death.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/did-saga/promise.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/did-saga/promise.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/did-saga/twfeworking.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/did-saga/twfeworking.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/diff-in-diff/cant-read.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/diff-in-diff/cant-read.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/diff-in-diff/non-parallel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/diff-in-diff/non-parallel.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/diff-in-diff/secrets.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/diff-in-diff/secrets.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/doubly-robust/double.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/doubly-robust/double.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/dummy/heterosk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/dummy/heterosk.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/dummy/you_little_shit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/dummy/you_little_shit.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/evaluate-causal-models/ate_bins.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/evaluate-causal-models/ate_bins.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/evaluate-causal-models/cumm_elast.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/evaluate-causal-models/cumm_elast.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/evaluate-causal-models/cumm_gain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/evaluate-causal-models/cumm_gain.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/evaluate-causal-models/sneak.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/evaluate-causal-models/sneak.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/evaluate-causal-models/uncivilised.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/evaluate-causal-models/uncivilised.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/fixed-effects/control-unit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/fixed-effects/control-unit.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/fixed-effects/demeaned.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/fixed-effects/demeaned.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/fixed-effects/fe-graph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/fixed-effects/fe-graph.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/fixed-effects/time-travel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/fixed-effects/time-travel.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/graph-flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/graph-flow.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/hte-binary-outcome/logistic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/hte-binary-outcome/logistic.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/hte-binary-outcome/slide-susan-athey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/hte-binary-outcome/slide-susan-athey.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/cascade-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/cascade-1.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/cascade-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/cascade-2.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/cashflow-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/cashflow-1.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/cross-validation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/cross-validation.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/ml-flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/ml-flow.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/ml-meme.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/ml-meme.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/model-fit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/model-fit.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/overfitting.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/overfitting.jpg
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/profit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/profit.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/test.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/industry-ml/translation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/industry-ml/translation.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/intro/anatomy1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/intro/anatomy1.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/intro/anatomy2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/intro/anatomy2.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/intro/anatomy3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/intro/anatomy3.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/intro/anatomy4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/intro/anatomy4.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/intro/potential_outcomes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/intro/potential_outcomes.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/intro/tougher-up-cupcake1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/intro/tougher-up-cupcake1.jpg
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/iv/good-iv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/iv/good-iv.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/iv/incomplete-files.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/iv/incomplete-files.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/iv/qob.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/iv/qob.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/iv/weak-iv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/iv/weak-iv.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/late/always_takers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/late/always_takers.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/late/defiers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/late/defiers.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/late/double_index.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/late/double_index.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/linear-regression/confused_cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/linear-regression/confused_cat.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/linear-regression/you_vs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/linear-regression/you_vs.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/matching/explain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/matching/explain.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/matching/its-a-match.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/matching/its-a-match.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/matching/ubiquitous-ols.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/matching/ubiquitous-ols.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/meta-learners/learned-new-move.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/meta-learners/learned-new-move.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/meta-learners/not-great-not-terrible.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/meta-learners/not-great-not-terrible.jpeg
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/meta-learners/s-learner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/meta-learners/s-learner.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/meta-learners/second-stage-x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/meta-learners/second-stage-x.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/meta-learners/t-learner-problem.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/meta-learners/t-learner-problem.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/meta-learners/t-learner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/meta-learners/t-learner.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/meta-learners/t-vs-x-learner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/meta-learners/t-vs-x-learner.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/meta-learners/x-learner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/meta-learners/x-learner.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/meta-learners/zero-bias-s-learner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/meta-learners/zero-bias-s-learner.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/orthogonal/athlas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/orthogonal/athlas.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/orthogonal/kfold-cv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/orthogonal/kfold-cv.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/orthogonal/nazare-confusa.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/orthogonal/nazare-confusa.jpg
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/plug-and-play-estimators/genious.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/plug-and-play-estimators/genious.jpeg
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/plug-and-play-estimators/infeasible.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/plug-and-play-estimators/infeasible.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/plug-and-play-estimators/linear-case.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/plug-and-play-estimators/linear-case.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/plug-and-play-estimators/non-linear-case.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/plug-and-play-estimators/non-linear-case.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/plug-and-play-estimators/second-estimator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/plug-and-play-estimators/second-estimator.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/poetry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/poetry.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/ps/balance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/ps/balance.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/ps/bootstrap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/ps/bootstrap.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/ps/iptw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/ps/iptw.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/ps/ml-trap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/ps/ml-trap.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/rct/indep.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/rct/indep.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/rct/lurking_bias.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/rct/lurking_bias.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/rct/science_dream.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/rct/science_dream.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/rdd/ols.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/rdd/ols.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/rdd/rdd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/rdd/rdd.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/rdd/rdd_fuzzy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/rdd/rdd_fuzzy.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/rdd/smooth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/rdd/smooth.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/sc-conformal-inf/aug-data.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/sc-conformal-inf/aug-data.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/sc-conformal-inf/block-perm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/sc-conformal-inf/block-perm.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/stats-review/ci_xkcd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/stats-review/ci_xkcd.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/stats-review/normal_dist.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/stats-review/normal_dist.jpeg
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/stats-review/p_value.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/stats-review/p_value.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/synth-control/allways.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/synth-control/allways.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/synth-control/extrapolation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/synth-control/extrapolation.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/synth-control/out-of-sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/synth-control/out-of-sample.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/synth-control/regr_space.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/synth-control/regr_space.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/synth-control/regr_space_x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/synth-control/regr_space_x.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/synth-control/regr_time.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/synth-control/regr_time.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/synth-control/synth_img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/synth-control/synth_img.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/flat-curves.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/flat-curves.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/graph-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/graph-1.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/graph-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/graph-2.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/graph-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/graph-3.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/horse-meme.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/horse-meme.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/ml-in-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/ml-in-5.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/model-opt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/model-opt.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/opt-deriv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/opt-deriv.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/pandas-magic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/pandas-magic.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/partitions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/partitions.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/personalise.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/personalise.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/slice-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/slice-1.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/slice-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/slice-2.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/waiting-time.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/img/when-prediction-fails/waiting-time.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/online_classroom.csv:
--------------------------------------------------------------------------------
1 | gender,asian,black,hawaiian,hispanic,unknown,white,format_ol,format_blended,falsexam
2 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,63.299969999999995
3 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,79.96
4 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,83.37
5 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,90.01994
6 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,83.3
7 | 0,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,88.34996
8 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,1.0,78.4
9 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,90.0
10 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,88.31
11 | 0,0.0,0.0,0.0,0.0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0.0,0.0,0.0,0.0,0.0,1,0.0,58.34
99 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,78.31
100 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,83.3
101 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,51.678999999999995
102 | 0,,,,,,,0,0.0,61.67997
103 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,76.66
104 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,56.70997
105 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,79.99996999999999
106 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,79.98
107 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,73.3
108 | 0,,,,,,,0,0.0,73.39
109 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,71.64996
110 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,79.97995
111 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,71.62997
112 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,1.0,79.98
113 | 0,,,,,,,0,0.0,86.64
114 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,83.39
115 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,64.979
116 | 1,,,,,,,1,0.0,93.39
117 | 0,,,,,,,0,0.0,70.03
118 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,84.97
119 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,89.98
120 | 1,,,,,,,1,0.0,56.65
121 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,78.34995
122 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,74.90996
123 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,78.31
124 | 0,0.0,0.0,1.0,0.0,0.0,0.0,1,0.0,81.7
125 | 0,0.0,1.0,0.0,0.0,0.0,0.0,0,0.0,66.64
126 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,86.64
127 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,79.98
128 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,81.65
129 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,84.97
130 | 0,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,76.71
131 | 0,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,60.08
132 | 0,,,,,,,0,1.0,91.65
133 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,75.06
134 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,80.05
135 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,81.67
136 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,86.65994
137 | 1,,,,,,,0,1.0,83.3
138 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,74.95997
139 | 0,,,,,,,0,0.0,69.95996
140 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,88.32994000000001
141 | 0,,,,,,,1,0.0,64.95
142 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,66.64
143 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,76.64
144 | 0,,,,,,,1,0.0,74.99
145 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,59.94
146 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,75.02
147 | 0,,,,,,,1,0.0,58.31
148 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,76.76
149 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,71.68
150 | 1,,,,,,,0,0.0,89.98
151 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,1.0,84.99
152 | 1,,,,,,,0,0.0,81.63
153 | 1,0.0,1.0,0.0,0.0,0.0,0.0,0,1.0,83.32
154 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,73.31997
155 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,73.27996999999999
156 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,88.38
157 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,68.36
158 | 0,,,,,,,0,1.0,68.29
159 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,71.63
160 | 1,,,,,,,0,1.0,71.63
161 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,91.65
162 | 1,,,,,,,0,0.0,68.31
163 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,75.02
164 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,73.44
165 | 0,0.0,1.0,0.0,0.0,0.0,0.0,0,1.0,50.1
166 | 1,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,63.31998000000001
167 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,70.03
168 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,73.32
169 | 0,,,,,,,1,0.0,83.3
170 | 1,,,,,,,1,0.0,75.06
171 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,86.66
172 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,1.0,68.32996
173 | 0,,,,,,,0,1.0,78.329
174 | 0,,,,,,,1,0.0,68.31
175 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,75.02
176 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,78.33
177 | 0,,,,,,,0,1.0,73.28
178 | 0,,,,,,,0,0.0,74.97
179 | 0,0.0,1.0,0.0,0.0,0.0,0.0,0,1.0,70.05
180 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,76.63996999999999
181 | 1,,,,,,,0,1.0,84.99
182 | 0,,,,,,,0,1.0,71.74
183 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,88.33
184 | 0,,,,,,,1,0.0,63.28
185 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,1.0,91.74
186 | 1,,,,,,,1,0.0,0.0
187 | 1,0.0,1.0,0.0,0.0,0.0,0.0,0,0.0,79.98
188 | 1,,,,,,,0,0.0,69.94
189 | 1,0.0,0.0,0.0,1.0,0.0,0.0,0,1.0,63.27997
190 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,84.99
191 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,73.3
192 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,88.33
193 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,83.29997
194 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,84.97
195 | 1,,,,,,,1,0.0,81.65
196 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,83.3
197 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,89.99994000000001
198 | 0,0.0,0.0,0.0,1.0,0.0,0.0,1,0.0,79.93996
199 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,78.29
200 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,86.64
201 | 1,,,,,,,0,0.0,91.67
202 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,76.75
203 | 0,0.0,1.0,0.0,0.0,0.0,0.0,0,1.0,73.28
204 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,70.03
205 | 1,,,,,,,0,0.0,83.32
206 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,90.0
207 | 1,,,,,,,0,1.0,83.32
208 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,83.3
209 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,78.31
210 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,88.33
211 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,83.37
212 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,86.66
213 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,86.66
214 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,84.99
215 | 1,0.0,1.0,0.0,0.0,0.0,0.0,0,0.0,88.33
216 | 1,0.0,0.0,1.0,0.0,0.0,0.0,0,1.0,88.33
217 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,81.65
218 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,78.229
219 | 1,,,,,,,0,1.0,76.73
220 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,89.98
221 | 1,,,,,,,0,1.0,74.95
222 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,1.0,75.02
223 | 0,,,,,,,0,1.0,56.759980000000006
224 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,81.669
225 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,58.27
226 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,81.63
227 | 0,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,58.299969999999995
228 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,78.38
229 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,81.72
230 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,84.99
231 | 0,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,81.67
232 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,86.66
233 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,88.31
234 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,65.02
235 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,80.0
236 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,1.0,78.37995
237 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,86.66
238 | 1,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,83.34
239 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,84.99
240 | 0,,,,,,,0,1.0,89.98
241 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,66.69
242 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,83.37
243 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,88.33
244 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,86.64
245 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,90.0
246 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,84.97
247 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,73.32
248 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,85.01
249 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,75.06
250 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,81.65
251 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,1.0,68.27
252 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,83.34
253 | 1,,,,,,,1,0.0,80.05
254 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,86.64
255 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,81.65
256 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,68.36
257 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,80.0
258 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,73.35
259 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,68.36
260 | 0,,,,,,,0,1.0,61.63
261 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,56.71
262 | 1,,,,,,,0,1.0,78.31
263 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,90.0
264 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,70.03
265 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,68.28996
266 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,76.73
267 | 1,,,,,,,1,0.0,86.65996
268 | 0,0.0,0.0,0.0,0.0,1.0,0.0,0,1.0,48.33998
269 | 1,0.0,1.0,0.0,0.0,0.0,0.0,1,0.0,81.7
270 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,81.72
271 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,56.59996999999999
272 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,81.65
273 | 1,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,94.99
274 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,59.92
275 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,61.68
276 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,86.64
277 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,86.66
278 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,88.31
279 | 1,,,,,,,1,0.0,81.7
280 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,1.0,68.34
281 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,78.4
282 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,74.97
283 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,83.32
284 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,84.99
285 | 1,0.0,0.0,0.0,1.0,0.0,0.0,1,0.0,76.62
286 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,68.36
287 | 1,,,,,,,0,1.0,76.62
288 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,66.62
289 | 0,,,,,,,1,0.0,74.90997
290 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,79.96
291 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,88.33
292 | 0,,,,,,,0,1.0,76.71
293 | 1,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,65.02
294 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,83.32
295 | 1,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,86.75
296 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,83.44
297 | 1,0.0,1.0,0.0,0.0,0.0,0.0,0,0.0,95.01
298 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,69.99996999999999
299 | 0,1.0,0.0,0.0,0.0,0.0,0.0,1,0.0,86.68
300 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,66.65899999999999
301 | 1,,,,,,,0,1.0,76.62
302 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,71.61
303 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,90.0
304 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,60.01
305 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,1.0,94.99
306 | 0,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,83.3
307 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,83.32
308 | 1,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,70.0
309 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,73.37
310 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,83.39
311 | 0,0.0,0.0,0.0,0.0,0.0,1.0,1,0.0,0.0
312 | 1,,,,,,,0,1.0,69.96
313 | 1,1.0,0.0,0.0,0.0,0.0,0.0,0,0.0,86.71
314 | 1,,,,,,,0,0.0,90.0
315 | 0,0.0,1.0,0.0,0.0,0.0,0.0,0,0.0,61.68
316 | 0,,,,,,,0,0.0,73.37
317 | 1,,,,,,,0,1.0,88.31
318 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,91.65
319 | 1,,,,,,,0,0.0,84.99
320 | 0,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,68.36
321 | 1,,,,,,,1,0.0,70.05
322 | 0,,,,,,,1,0.0,66.69
323 | 1,,,,,,,1,0.0,83.29997
324 | 1,0.0,0.0,0.0,0.0,0.0,1.0,0,1.0,96.68
325 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/sheepskin.csv:
--------------------------------------------------------------------------------
1 | minscore,person_years,avgearnings,receivehsd,n
2 | -30.0,24.0,11845.086,0.41666666,12
3 | -29.0,104.0,9205.679,0.38709676,31
4 | -28.0,146.0,8407.745,0.3181818,44
5 | -27.0,137.0,11114.087,0.37777779,45
6 | -26.0,227.0,10814.624,0.30666667,75
7 | -25.0,341.0,11666.925,0.3018868,106
8 | -24.0,419.0,11336.057,0.38059703,134
9 | -23.0,479.0,10719.352,0.275,160
10 | -22.0,550.0,10684.487,0.26666668,180
11 | -21.0,756.0,10342.762,0.23673469,245
12 | -20.0,839.0,11012.137,0.26335877,262
13 | -19.0,1029.0,11721.943,0.28783384,337
14 | -18.0,1175.0,11712.557,0.28350514,388
15 | -17.0,1424.0,10564.079,0.26444444,450
16 | -16.0,1549.0,10737.608,0.29554656,494
17 | -15.0,1854.0,11423.25,0.30993152,584
18 | -14.0,2092.0,11717.597,0.30225563,665
19 | -13.0,2443.0,11931.299,0.28188777,784
20 | -12.0,2924.0,12174.198,0.28349945,903
21 | -11.0,3058.0,11953.884,0.29771784,964
22 | -10.0,3505.0,12705.653,0.30483273,1076
23 | -9.0,3986.0,12060.475,0.34561834,1221
24 | -8.0,4394.0,12214.287,0.34626648,1366
25 | -7.0,4931.0,13038.381,0.35818908,1502
26 | -6.0,5574.0,12683.077,0.37507418,1685
27 | -5.0,5706.0,13179.544,0.39025787,1745
28 | -4.0,6530.0,13083.809,0.39937598,1923
29 | -3.0,6438.0,13143.415,0.4405812,1927
30 | -2.0,6869.0,13983.55,0.45413533,1995
31 | -1.0,6667.0,13732.518,0.46518824,1939
32 | 0.0,6458.0,14063.868,0.916222,1874
33 | 1.0,6548.0,14257.279,0.9062334,1877
34 | 2.0,5850.0,13829.307,0.9275449,1670
35 | 3.0,5484.0,14631.656,0.9151671,1556
36 | 4.0,5219.0,14847.078,0.9280677,1418
37 | 5.0,4654.0,14983.756,0.9230159,1260
38 | 6.0,3874.0,14936.146,0.9325736,1053
39 | 7.0,3392.0,15824.566,0.93134,903
40 | 8.0,2653.0,15175.247,0.9410072,695
41 | 9.0,2220.0,15253.268,0.9256637,565
42 | 10.0,1869.0,16395.117,0.93432206,472
43 | 11.0,1466.0,15541.161,0.9222222,360
44 | 12.0,1052.0,15487.525,0.96564883,262
45 | 13.0,761.0,17235.902,0.9673913,184
46 | 14.0,474.0,16985.027,0.9357798,109
47 | 15.0,308.0,17854.611,0.87323946,71
48 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/trainees.csv:
--------------------------------------------------------------------------------
1 | unit,trainees,age,earnings
2 | 1,1,28,17700
3 | 2,1,34,10200
4 | 3,1,29,14400
5 | 4,1,25,20800
6 | 5,1,29,6100
7 | 6,1,23,28600
8 | 7,1,33,21900
9 | 8,1,27,28800
10 | 9,1,31,20300
11 | 10,1,26,28100
12 | 11,1,25,9400
13 | 12,1,27,14300
14 | 13,1,29,12500
15 | 14,1,24,19700
16 | 15,1,25,10100
17 | 16,1,43,10700
18 | 17,1,28,11500
19 | 18,1,27,10700
20 | 19,1,28,16300
21 | 20,0,43,20900
22 | 21,0,50,31000
23 | 22,0,30,21000
24 | 23,0,27,9300
25 | 24,0,54,41100
26 | 25,0,48,29800
27 | 26,0,39,42000
28 | 27,0,28,8800
29 | 28,0,24,25500
30 | 29,0,33,15500
31 | 31,0,26,400
32 | 32,0,31,26600
33 | 33,0,26,16500
34 | 34,0,34,24200
35 | 35,0,25,23300
36 | 36,0,24,9700
37 | 37,0,29,6200
38 | 38,0,35,30200
39 | 39,0,32,17800
40 | 40,0,23,9500
41 | 41,0,32,25900
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/graph-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/graph-1.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/graph-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/graph-2.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/graph-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/graph-3.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/horse-meme.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/horse-meme.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/ml-in-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/ml-in-5.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/model-opt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/model-opt.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/opt-deriv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/opt-deriv.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/pandas-magic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/pandas-magic.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/partitions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/partitions.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/personalise.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/personalise.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/slice-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/slice-1.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/slice-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/slice-2.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/data/when-prediction-fails/waiting-time.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CausalInferenceLab/Causal-Inference-with-Python/c4c824141fb4017fba05327ed0dae6f4d522bfde/causal-inference-for-the-brave-and-true/data/when-prediction-fails/waiting-time.png
--------------------------------------------------------------------------------
/causal-inference-for-the-brave-and-true/landing-page.md:
--------------------------------------------------------------------------------
1 | # Causal Inference for The Brave and True
2 |
3 | 안녕하세요. [가짜연구소](https://pseudo-lab.com/) 빌더 [신진수](https://www.linkedin.com/in/jinsoo-shin-436060162/)입니다. 가짜연구소 인과추론팀은 한국어 자료가 많지 않은 인과추론을 많은 분들이 쉽게 접하실 수 있도록 기여하고자 합니다!
4 |
5 | ## 책 번역 및 도입
6 |
7 | 이 책은 Matheus Facure (Nubank Data Scientist)의 [Causal Inference for The Brave and True](https://matheusfacure.github.io/python-causality-handbook/landing-page.html)을 한국어로 번역한 자료입니다. 이 책은 인과추론에 대한 기본 개념과 Python 실습, 나아가 최신 사례까지 모두 다루고 있습니다. 인과추론에 대한 이론과 실습자료가 많지 않은 상황에서 이 책은 인과추론 처음 접하거나 인과추론에 대한 이해를 바탕으로 사례를 접하고 싶은 분 모두를 만족시킬 수 있는 책이라고 생각합니다. 한국에서 인과추론을 공부하시는 분들께 많은 도움이 되었으면 좋겠습니다.
8 |
9 | 가짜연구소 Causal Inference 팀은 전문 번역가가 아닌, 데이터분석가/과학자/연구자로 구성 되어 있습니다. 따라서, 한국어 번역 과정에서 이상하거나 어색한 부분이 발생할 수 있어요. 해당 부분에 대한 여러분의 피드백을 부탁드립니다. 또한, 한국어 표현이 익숙하지 않은 부분에 대해서는 영어로 그대로 표현했습니다. 해당 부분 이해부탁드려요.
10 | 여러분의 관심은 꼭 스타로 표현해주세요!
11 |
12 | 마지막으로, 이 책의 한국어 번역에 동의해 주신 Matheus Facure에게 감사의 말씀을 전합니다.
13 | 그리고, 번역과 실습자료를 만들기 위해 같이 고생해준 Causal Inference 팀 멤버들에게도 진심으로 감사드립니다!
14 |
15 | 이 책은 Joshua Angrist, Alberto Abadie, Christopher Walters, Miguel Hernan 및 Jamie Robins 등을 포함한 많은 연구자들의 계량 경제학 수업과 바탕으로 하고 있으며, 대부분의 아이디어는 전미경제학회(American Economic Association)의 수업에서 가져왔습니다. 이 책을 작성하기 위해 참고한 자료와 서적은 아래와 같습니다.
16 |
17 | * [Cross-Section Econometrics](https://www.aeaweb.org/conference/cont-ed/2017-webcasts)
18 | * [Mastering Mostly Harmless Econometrics](https://www.aeaweb.org/conference/cont-ed/2020-webcasts)
19 | * [Mostly Harmless Econometrics](https://www.mostlyharmlesseconometrics.com/)
20 | * [Mastering 'Metrics](https://www.masteringmetrics.com/)
21 | * [Causal Inference Book](https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/)
22 |
23 | ## 자료 이슈 및 관련 질문
24 | 번역 자료에 대한 이슈가 있다면, 해당 Github 저장소의 [이슈 페이지](https://github.com/CausalInferenceLab/Causal-Inference-with-Python/issues)를 방문해주세요. 또한, 관련 질문은 빌더인 [신진수](https://github.com/jsshin2022)에게 문의 부탁드립니다.
--------------------------------------------------------------------------------