Hack Your Way To Scientific Glory (recreation)

You’re a social scientist with a hunch: The U.S. economy is affected by whether Republicans or Democrats are in office. Try to show that a connection exists, using real data going back to 1948. For your results to be publishable in an academic journal, you’ll need to prove that they are “statistically significant” by achieving a low enough p-value.

Recreation of FiveThirtyEight’s “Hack Your Way To Scientific Glory” (archived here), but with Observable JS.

Code and data

1 Choose a political party

2 Define terms

Which politicians do you want to include?


How do you want to measure economic performance?


Other options

Weight more powerful positions more heavily

Don’t include economic recessions

3 Is there a relationship?

Given how you’ve defined your terms, does the economy do better, worse or about the same when more Democrats are in power? Each dot below represents one month of data.

4 Is your result significant?

If there were no connection between the economy and politics, what is the probability that you’d get results at least as strong as yours? That probability is your p-value, and by convention, you need a p-value of 0.05 or less to get published.


If you’re interested in reading real (and more rigorous) studies on the connection between politics and the economy, see the work of Larry Bartels and Alan Blinder and Mark Watson.

Data from The @unitedstates Project, National Governors Association, Bureau of Labor Statistics, Federal Reserve Bank of St. Louis and Yahoo Finance.