I projected election outcomes in battleground states every three minutes during the 2020 presidential elections.

I’m scraping from the Times each vote block that comes in. I calculate each candidate’s margin over the last 30k votes, and take the simple moving average. Assuming their margin will continue, I project the anticipated result of the race.

Big grain of salt: this projection does not account for the underlying demographics of the outstanding counties. It assumes the next 30k votes will be drawn from the same distribution as the past 30k votes.

My confidence in the projection is based on three factors:

  • The number of ballots remaining to be counted. (More uncounted ballots means more uncertainty).

  • The margin of the race by vote count. (Lower margin means more uncertainty).

  • The “assurance”: the observed vote margin (the rolling average, described above) minus the bare minimum vote margin needed for a threadbare victory. (Say a candidate got 68% on the last 30k votes, and need at least 60% on the votes that remain to be counted. The number will be 8%.) The higher that number is, the more confident we can be in the projection.

Confidence is 1/remaining_ballots * margin * assurance. Don’t interpret it as a percentage (that formatting is just for readability)! But higher means more confidence.

NOTE: Sometimes, like when Georgia is counting military ballots, we don’t know how many ballots remain, making a forecast impossible. When that happens, I just show the current margins and whether or not the race is “tightening” (whether the underdog getting the margins on new ballots they would need to pull ahead, assuming enough ballots exist for them to do so).