So Yep… I Made Another Election Model

Python
Stats
Dataviz
Politics
Published

March 4, 2024

There are a lot of election models out there - fivethirtyeight, The Cook Political Report, and Decision Desk to name a few. So what am I doing here?

TLDR

View my personal election model in my dashboard 👉👉 here 👈👈

The Problem

Well, it may be the start of a tradition at this point since I did one last US presidential election and I thought it actually performed quite well (election was close; my latest simulations also close). But, in the end, I created this because I felt like I was blindly trusting other’s models without understanding them. Many election model builders claim to use demographic patterns, previous election results, economic considerations, polls, etc.. But, beside polling numbers, what data exactly are they using and where does it come from? Also, what do their models actually look like? Ideally, I would want enough information to recreate the model myself to see what they actually did, but that information is rarely available.

What I did

My goal was to create a model that is based exclusively on recent quality polling, and that’s it! No mysterious variables thrown into already complex models; no sensitive consumer data that feels like violations of privacy; and, no blindly trusting an invisible methodology where you can’t possibly recreate the model. Since I finished data science school within the last four years, I decided to take a more rigourous approach than last time which I write about here and code up here. Overall, the purpose is to give an educated guess of what would happen if the election were held each day. I also just like this kinda thing 😂.

Note

The dashboard is part of an automated data pipeline that updates each day until the election. So check back soon! Each day at around 5am, the charts are updated with the latest quality polling data.

So, thanks for viewing this post! Check back soon for more updates on the dashboard. Feel free to share thoughts, comments, or your predictions below in the comments section at the end of the page. Below, I included a few notes with more info on each graph in the dashboard in layman’s terms.


Miscellaneous Technical and Graph Notes

  • I simulate the election 50,000 times each day based off of modeled probabilities of Trump winnin each state. The model isn’t necessarily a forecast because I am simulating the election as if it were held the present day.
  • Notice that you still see both candidates win some simulations. Even though one outcome may be more likely, don’t count the other out!
Histogram Notes
  • See how the histogram of daily EC vote distribution is more spikey than smooth? This is because some outcomes with even 1 EC point difference can be more likely given how state groupings naturally divide out.
Choropleth Map Notes
  • Watch states like Georgia and Arizona closely which had unexpected results last election. Also, keep an eye on light colored states where the winner is more uncertain!
  • Districts from States using the congressional district method are not included on the map, but they are included in the model!
Win Perc. Over Time Graph Notes
  • I decided to create a confidence interval around the final graph of win percentages per candidate tracked over time. To accomplish this, I take 1000 samples of the simulations (n=100) and record the 2.5 and 97.5 percentile of the sample means. This is by no means a perfect measure for a confidence interval, but should provide a sense of possible win percentages day by day.