luka.gouvea
← projects
Academic project · INF425 at UFV · 2026

Convergence of election projections

Comparison of three methods that project Brazil's presidential runoff during the vote count, in the 2018, 2022 and 2026 elections, with the actual order in which polling sections arrived reconstructed from TSE data.

Context

During the count, polling sections do not arrive in random order: whole regions are counted before others, and the running tally can sit several points away from the final result. Projection methods correct for this by estimating the votes still to be counted from what has already been counted and from each municipality’s history.

The question is how many counted sections each method needs to get close to the final result and stay close. Done with Gabriel Campos Moreira Fernandes.

Data and protocol

Methods

All three keep the counted votes fixed and estimate only the remaining ones, municipality by municipality. The expected volume of each pending section comes from first-round valid votes, adjusted by the turnout observed so far.

The estimators are written in PyTorch and run on CPU. The environment is a Docker image with pinned versions, and a script reruns the 927 projections and compares them with the recorded ones at a 1e-10 tolerance.

Results

Projection during the count

Projected final result for each candidate (solid line) and the running tally at the same point (dashed), in the order used by the replay.

  • Haddad · projection
  • Jair Bolsonaro · projection
  • Haddad · tally
  • Jair Bolsonaro · tally

2018 · Post-stratification

303540455055606570020406080100Sections counted (%)Valid votes (%)
From 1% of sections onward. Hover, or use the arrow keys with the chart focused, to read the values.

Comparing the methods

  • Post-stratification
  • Swing
  • Hierarchical
  • Running tally
  • Final result
  • ±0.5 pp of final

2018 · Fernando Haddad × Jair Bolsonaro

43.043.544.044.545.045.546.0020406080100Sections counted (%)A's valid votes (%)
Projected vote share of the PT candidate (A) by the three methods. The running tally is off the scale early in the 2018 and 2022 counts.

Error with 5% of sections counted

In percentage points, on A’s final vote share.

2018 2022 2026
Running tally 4.99 4.27 0.62
Post-stratification 0.58 0.35 1.10
Swing 0.59 0.06 0.24
Hierarchical 0.16 0.12 0.34

Convergence point

Percentage of sections after which the error stays below the threshold until the end of the count.

2018 2022 2026
Threshold (pp) 1.0 0.5 0.25 1.0 0.5 0.25 1.0 0.5 0.25
Post-stratification 41% 76% 88% 3% 63% 79% 21% 25% 45%
Swing 23% 52% 63% 0.1% 30% 64% 0.1% 2% 58%
Hierarchical 24% 53% 80% 0.1% 44% 71% 0.1% 39% 47%

We also estimated uncertainty bands by bootstrap, with 200 refits per point. Their measured coverage was low, so they do not work as a margin of error and are left out of this page.

Limitations

Stack

Python · PyTorch · Pandas · Parquet · Weighted regression · Ridge · Docker