HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
TheEconomist
us-potus-model
HTML2020–2024
TheEconomist / us-potus-model

us-potus-model

Code for a dynamic multilevel Bayesian model to predict US presidential elections. Written in R and Stan.

4Distinct people
4Mentions
0Explicit recommenders
1.3KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Code for a dynamic multilevel Bayesian model to predict US presidential elections. Written in R and Stan.

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 5:04:57 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year4 dated mentions

Observed mentions: 2020-06-14 11:51:39 UTC to 2024-06-16 20:29:13 UTC.

01232020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 3 mentions; 2 submissions, 1 comments20202021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20222023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2024

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC321
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC000
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC000
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC101

What Hacker News says

4 sources
This sounds like a more thorough update to the 2020 model they published here: https://github.com/TheEconomist/us-potus-model Nate Silver was both the best and worst thing that happened to these predictions. The modus operandi of people in media (New York and Hollywood) is "gut checks" - Dean Baquet is only going to publish a model, no matter what the math says, that agrees with his "gut" that Clinton was going to win 2016. He was so crazy wrong but like, he's not getting fired. Laypeople and cranks conflate making a mistake that everyone in media made with a conspiracy between Democrats and the media, unable to grasp incompetence. Of course, if Dean Baquet had spent five minutes talking to a political scientist of some merit, asking, "is the voter turnout of traditional demographic groups like women and old people is really as predictive
Read the rest
of elections as Nate Silver said it was?" He would have learned that Australia has had compulsory voting for decades and it is as conservative as ever. Now that "gut checks" have disentangled themselves from New York graphics departments - can you believe its the graphics department, masquerading as a "data science" department, that runs election forecast stories?! - maybe forecasts will be better everywhere. If I were doing this, I'd frame it as a Kaggle competition built on PyroPL. And I'd require top performance in democratic election forecasting everywhere, not just the US. The Economist is right, it's all about fundamentals, but which fundamentals, and can you prevent the choice of fundamentals from reflecting the publisher's political aspirations? Personally I'm skeptical that the Economist's choice of GDP growth makes any sense, and net approval rating sounds like a poll, so... there must be something better.
In How The Economist’s presidential forecast works
538 does rank pollsters based on "historical accuracy and methodology"[1], which are then weighted accordingly in their prediction model. And Nate and Elliot Morris (from the economist) have talked about how polling error tends to be normally distributed, so using multiple pollsters with different biases could correct for polling error. Pollsters are picking representative samples and weighting it to reflect the population, so it's not like they're just counting on who picks up their phone (and phone calls aren't the only way to poll anymore anyway). As I recall, in 2016 the pollsters did oversample college-educated white voters, which is what gave Clinton her misleading lead. This apparently has been fixed. There's also the fact that any demographic under or oversampling should be accounted for in the uncertainty range produced by the pr
Read the rest
ediction. I haven't been able to find decent write-ups of this particular part of model forecasting, but from what I've been able to piece together : I believe they quantify the uncertainty of their presidential predictions by building logistic regressions of the output based on highly-correlated predictor data (i.e demographic information, GDP) and then simulating thousands of possible scenarios where demographics trend differently. I don't exactly know how these simulations are set up (I would love to know though). And presumably this is updated in a bayesian matter everytime they get more input data, so the prior probabilities will have an impact on the posterior. If anyone has a different or more detailed idea of how this is done, let me know. In fact, here's the actual code for Elliot Morris' forecasting model: https://github.com/TheEconomist/us-potus-model if anyone can figure it out better then me. [1] https://projects.fivethirtyeight.com/pollster-ratings/ [2] https://www.vox.com/21538156/biden-polls-lead-election-trump...
In Put not thy trust in Nate Silver

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.