jrfiedler / causal_inference_python_code

Python code for part 2 of the book Causal Inference: What If, by Miguel Hernán and James Robins
1.24k stars 385 forks source link

added legend in chapter12 #1

Closed piyushmadan closed 6 years ago

piyushmadan commented 6 years ago

Added legend to check for positivity in chapter 12 analysis.

image

piyushmadan commented 6 years ago

@jrfiedler The notebook works for 3.5.3 and not 3.6. I can write a Docker environment with correct python environment and jupyter notebook if that helps.

With python 3.6, in cell 17, most of the denoms are zero because of which weights (=1/denoms) are inf

jrfiedler commented 6 years ago

Thanks, @piyushmadan. No need to write a Docker environment. I will review this now.

jrfiedler commented 6 years ago

The code looks good. One minor thing: the semicolon after ax.set_ylabel('count') should probably either be moved down a line or removed. If you want to fix that, great. If not, it's pretty minor, so I won't hold up the pull request for that.

I'm not getting the same result for cell 17. I developed the code in Python 3.6 and it's running fine for me. See the picture below. In this example I inserted a couple checks after cell 17 and verified that I'm using Python 3.6.

image