Simpson’s Paradox

As noted previously, e.g. in this post, care must be taken with statistics…


Simpsons Paradox & R0

Thanks to Richard McElreath’s Baysian Inference class, I happened to have the data from the example on Simpson’s Paradox in the University Admissions example given in the article.

It’s a very illustrative example on what’s called “Confounding” or “Confounds” in statistics:  basically, a confound is some unobserved variable that impacts the variables in the model, and can often wreck havoc with causal inferences, e.g. by reversing them.

In the UCB example, the hypothesis was that since only 30% of women got admitted to PhD programmes, while the acceptance rate for men was over 40%, there must be gender discrimination in play, i.e. that the admission board discriminated women.

Only by identifying the confounders – in this case, the Departments of the University – did it become clear that there was no discrimination by the admission board – the reason women had a lower overall acceptance rate was because they on average applied to departments that accept very few students, while men on average applied to other departments, with much larger acceptance.

So, by “controlling for” the confounder, that is, the department, the hypothesis that the acceptance board discriminated women could be refuted.

Below a quick Python hack to illustrate this.

[before you run this code, make sure you don’t have anything named ‘share’ in your current directory!]



import os

os.system('rm -rf share')
os.system('git clone')

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd


df = pd.read_csv('./share/UCBadmit.csv',sep=';')

pivot = pd.pivot_table(df,index='dept',

pivot['applications_f'] = pivot[('applications','female')] / \

pivot['applications_m'] = pivot[('applications','male')] / \

pivot['admit_pct_f'] = pivot[('admit','female')] / \

pivot['admit_pct_m'] = pivot[('admit','male')] / \

pivot['admit_pct_tot'] = pivot[('admit','All')] / \

pivot['female_less'] = pivot['admit_pct_f'] < pivot['admit_pct_m']

print (pivot.head(20))



About swdevperestroika

High tech industry veteran, avid hacker reluctantly transformed to mgmt consultant.
This entry was posted in Epidemics, Statistics and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s