Block 3: Bayes’ rule: predicting race

Week 9 · Probability I · Imai §6.2.2 · about 4 min

NoteHow this works

Run each cell with Run Code, look at the output, then answer the question at the end of the block. Every cell is editable; Start Over resets it. Errors are information: read them.

We predict a voter’s race from their surname and residence using Bayes’ rule. names.csv: for each surname, the percent of Americans with that surname in each race group, i.e. \(P(\text{race} \mid \text{surname})\).

This block loads about 8 MB of data and runs the whole Bayes pipeline (Steps 1 to 4 on the slides) in the background. The first run takes a while.

1. The surname table

2. How often is the predicted race correct?

Accuracy of predicting race from the surname only, and after adding the precinct with Bayes’ rule, for each group.

Conclusion: Which group gains most in accuracy when the precinct is added?
Surname alone fails for Black voters (16%): many share surnames common among whites (WHITE: 27% black, 68% white). The precinct changes the prior, and accuracy rises to 63%. Voters named White: the posterior P(black) ranges from under 1% to 98%.