What Brazil's runoff counts can and cannot tell you
Brazil's official counts prove at least 4.78M runoff votes came from first-round blank, null or non-voters. Beyond that, only 6 of 32 voter movements estimated by a model passed two sets of test elections with known answers, and a guess with no model, checked after the results, passes the same 6.
Brazil's 2026 presidential runoff, on 25 October between Lula and Flávio Bolsonaro, followed a first round on 4 October with twelve candidates, and the ballot is secret: there are only the official totals for each of 499,206 polling sections. A flow is the share of one first-round group going to one runoff choice; a model estimated all 32 and was tested on planted elections, built on the real first-round map, where the right answer is known. Passing meant staying within 5 points on every planted election and within 10 points across the model's settings: 12 flows passed in a first set, which also chose those settings, and only 6 after a second set from a separate author, never used to choose or change anything. Those 6 all go blank or null, and none was tested at the size the model estimates, so the page gives ranges and no single number. The model's lean toward Lula among non-voters and blank or null voters was never tested against the opposite answer, because every planted election leaned that way too.
What I would do with this: report what the counts prove as fact, treat no flow as measured, and score any model on known answers, beside a guess with no model, before trusting a flow.
| Certain, from the counts4.78Mat least this many runoff votes for a finalist came from people who voted blank, null or not at all in the first round | From the section counts96 pointsalmost no limit on where a minor candidate's voters went: on average, each of those flows can lie anywhere in a range this wide, out of 100 (runoff counts scaled to each section's first-round register) | Self-test, then independent test12, then 6of 32 flows passed: within 5 points on every planted election and within 10 points across the model's settings; the 6 that fell all involve staying home, the flows the self-test had made look safe | Passes with no model6 of 6the same 6 would pass if you guessed 2.62%, the share of registered voters who voted blank or null in the runoff, for every flow (4 of them even on zero); a check added after the results, not one of the declared rules |
Main limitation Beyond the certain bounds every flow is a model estimate from polling-section totals. The independent test is 6 kinds of behaviour from one author: passing it shows the model survived those, not that it works on the real vote. | |||
Official totals for president, first round and runoff
Every total and its change is in the evidence.
In plain words
When an election goes to a second round, everyone wants to know where the eliminated candidates' voters went. The ballot is secret. What exists is each area's totals in each round, and reading individual moves from area totals is called ecological inference. A business meets the same problem whenever it sees only totals: the plan mix per region before and after a price change, sales per store before and after a product is discontinued, a market after a competitor leaves.
Decisions get made on those flows: which customers to win back, which product to stock, where a campaign should go. A model will always produce a flow for every pair, and a wrong one looks exactly as solid as a right one.
The answer this study gives: separate what the totals prove from what a model says, and test the model where the right answer is known, on tests it never got to choose, before trusting any flow. Here the totals prove two lower bounds. A model of the rest passed 12 of 32 flows on planted elections that also chose its settings; only 6 of those also passed a second set, written by a separate author and never used to tune it.
The election data is real: the official results of Brazil's Superior Electoral Court for every polling section, in both rounds, which add up to its national totals exactly. The planted elections are synthetic: the real first-round map with known runoff behaviour planted on it, in 7 forms in the first set and 6 in the second, three random draws each, so the model can be scored against the truth.
- Ecological inference
- Estimating how many people moved from one choice to another from totals per area.
- Flow
- The share of one first-round group going to one runoff choice, as the model estimates it.
- Did not vote
- Registered voters who cast no ballot: 21% in the first round and 19% in the runoff.
- Blank or null
- A ballot cast for no candidate.
- Planted election
- A simulated runoff on the real first-round map, where each area's flows are set in advance, so the model's answer can be scored.
- Self-test
- Planted elections that also chose the model's settings, which flatters the score.
- Independent test
- Planted elections written by a separate author who never saw the model's code or its results, though the author had read the written plan, which names the kind of model and the 5-point bar, and whose predictions describe an earlier run in words; never used to choose or change anything, and scored once on the final model.
- Passed every rule
- At most 5 points off on every planted election of both tests, and at most 10 points across the model's settings. The result files call such a flow recovered. This page does not, because one fixed share passes these flows too.
- Fixed share
- One number said for every flow, with no model: here the runoff's blank or null votes as a share of registered voters, 2.62%.
- Points of the group
- Errors are in percentage points of the first-round group: 5 points of Lula's 53.9M first-round voters is about 2.7M people.
- Not recovered
- The model's number for that flow failed a test: off by more than 5 points on some planted election, or moved more than 10 points when the model's settings changed. The page gives no single number for it, only the range its settings span. It does not mean the flow can never be known, only that this model did not recover it.
The evidence
What the official counts prove
Both rounds use the same national voter register, 158,745,502 electors in each, and every ballot is accounted for: candidate votes plus blank and null votes equal turnout exactly in each round. The two bounds below rest on that and on one ballot per person per round, nothing else.
| Choice | First round | Runoff | Change |
|---|---|---|---|
| Lula | 53,879,538 | 64,256,232 | +10.38M |
| Flávio Bolsonaro | 56,104,503 | 59,826,041 | +3.72M |
| Ten other candidates | 9,316,747 | 0 | −9.32M |
| Blank or null | 5,975,047 | 4,153,801 | −1.82M |
| Did not vote | 33,469,667 | 30,509,428 | −2.96M |
| Registered voters | 158,745,502 | 158,745,502 | 0 |
- At least 4.78M runoff votes for a finalist came from first-round blank, null or non-voters. The finalists received 124,082,273 votes in the runoff. Even if every one of the 119,300,788 first-round candidate voters voted for a finalist again, they fill at most 119,300,788 of them; the other 4,781,485 had to come from people who did not vote for a candidate in the first round. The true number is higher by however many first-round candidate voters went blank, null or stayed home in the runoff, which the counts cannot see.
- At least 1.05M of Lula's runoff voters had voted for Flávio, blank, null or not at all. Lula gained 10,376,694 votes; all ten other candidates together had 9,316,747. Even if he kept every first-round voter and won every minor candidate's voter, 1,059,947 votes are still unaccounted for. The bound is deliberately weak: any first-round voter he lost, or any minor-candidate voter who went elsewhere, raises the true number. No such bound exists for Flávio: his gain, 3,721,538, is smaller than the minor-candidate pool, so all of it could have come from those voters.
Beyond these, the counts allow almost anything. The bounds that follow from each polling section's totals alone leave every minor candidate's flow between 0 and at least 78% of the group (an average width of 96 points), and allow up to 74% of Lula's and 78% of Flávio's voters to have switched to the other finalist. These per-section bounds take one step the two above do not: where a section's register changed between the rounds, its runoff counts are scaled to its first-round register.
What the model estimates
Votes moving from each first-round choice (left) to each runoff choice (right), model estimate
Passed every rule: within 5 points in both tests, within 10 across settingsNot recovered
Show the data
| Flow | Model, % of group (range across settings) | Largest error, self-test, points | Largest error, independent test, points | Planted, % of group* | Passes with no model?* | Section counts allow | Verdict |
|---|---|---|---|---|---|---|---|
| Lula to Lula | 95.2 to 99.7% | 9.5 | 10.0 | 88.9 to 95.9% | No | 9 to 100% | Not recovered |
| Lula to Flávio Bolsonaro | 0.0 to 1.5% | 7.2 | 2.1 | 0.5 to 3.6% | Zero and 2.62% | 0 to 74% | Not recovered |
| Lula to Blank or null | 0.0 to 1.2% | 0.7 | 0.8 | 0.9 to 1.7% | Zero and 2.62% | 0 to 8% | Passed every rule |
| Lula to Did not vote | 0.2 to 2.3% | 2.2 | 11.1 | 2.5 to 6.6% | 2.62% | 0 to 54% | Not recovered (passed the self-test only) |
| Flávio Bolsonaro to Lula | 0.0 to 1.9% | 8.3 | 0.8 | 0.8 to 5.9% | 2.62% | 0 to 78% | Not recovered |
| Flávio Bolsonaro to Flávio Bolsonaro | 94.5 to 98.3% | 6.5 | 8.8 | 88.5 to 94.7% | No | 5 to 100% | Not recovered |
| Flávio Bolsonaro to Blank or null | 0.0 to 1.2% | 0.5 | 1.1 | 1.0 to 1.9% | Zero and 2.62% | 0 to 8% | Passed every rule |
| Flávio Bolsonaro to Did not vote | 0.9 to 2.6% | 1.9 | 10.5 | 3.0 to 7.0% | 2.62% | 0 to 52% | Not recovered (passed the self-test only) |
| Augusto Cury to Lula | 47.1 to 55.1% | 30.6 | 41.4 | 25.0 to 71.1% | No | 0 to 100% | Not recovered |
| Augusto Cury to Flávio Bolsonaro | 27.2 to 32.9% | 15.9 | 4.2 | 15.0 to 59.9% | No | 0 to 100% | Not recovered |
| Augusto Cury to Blank or null | 9.2 to 21.8% | 4.0 | 0.5 | 1.9 to 5.4% | 2.62% | 0 to 84% | Not recovered (within 5 points in both tests, moved more than 10 across settings) |
| Augusto Cury to Did not vote | 0.0 to 8.3% | 10.8 | 37.1 | 4.9 to 27.2% | No | 0 to 100% | Not recovered |
| Renan Santos to Lula | 30.8 to 41.9% | 31.8 | 26.8 | 25.0 to 50.7% | No | 0 to 100% | Not recovered |
| Renan Santos to Flávio Bolsonaro | 35.4 to 50.7% | 17.1 | 3.6 | 27.6 to 59.9% | No | 0 to 100% | Not recovered |
| Renan Santos to Blank or null | 11.0 to 16.8% | 4.0 | 0.6 | 2.0 to 4.3% | Zero and 2.62% | 0 to 87% | Passed every rule |
| Renan Santos to Did not vote | 0.0 to 18.0% | 10.8 | 26.8 | 4.6 to 32.3% | No | 0 to 100% | Not recovered |
| Ronaldo Caiado to Lula | 30.8 to 35.8% | 32.3 | 23.7 | 18.6 to 48.0% | No | 0 to 100% | Not recovered |
| Ronaldo Caiado to Flávio Bolsonaro | 50.5 to 59.7% | 17.6 | 3.9 | 43.4 to 72.5% | No | 0 to 100% | Not recovered |
| Ronaldo Caiado to Blank or null | 6.0 to 12.3% | 4.0 | 2.0 | 1.9 to 4.3% | Zero and 2.62% | 0 to 79% | Passed every rule |
| Ronaldo Caiado to Did not vote | 0.0 to 7.0% | 10.8 | 25.4 | 5.4 to 31.3% | No | 0 to 100% | Not recovered |
| Seven other candidates to Lula | 15.8 to 34.5% | 33.7 | 32.6 | 25.0 to 53.3% | No | 0 to 100% | Not recovered |
| Seven other candidates to Flávio Bolsonaro | 48.0 to 78.9% | 19.1 | 17.0 | 22.2 to 59.9% | No | 0 to 100% | Not recovered |
| Seven other candidates to Blank or null | 3.7 to 13.6% | 4.0 | 1.8 | 1.9 to 6.3% | 2.62% | 0 to 99% | Passed every rule |
| Seven other candidates to Did not vote | 0.0 to 16.2% | 10.8 | 43.0 | 5.6 to 40.3% | No | 0 to 100% | Not recovered |
| Blank or null to Lula | 57.2 to 74.4% | 4.4 | 19.4 | 34.7 to 58.1% | No | 0 to 100% | Not recovered |
| Blank or null to Flávio Bolsonaro | 0.0 to 7.4% | 9.2 | 7.4 | 16.0 to 36.4% | No | 0 to 100% | Not recovered |
| Blank or null to Blank or null | 22.4 to 35.6% | 1.6 | 3.4 | 5.4 to 34.6% | No | 0 to 66% | Not recovered (within 5 points in both tests, moved more than 10 across settings) |
| Blank or null to Did not vote | 0.0 to 5.3% | 4.1 | 30.1 | 6.4 to 14.8% | No | 0 to 100% | Not recovered (passed the self-test only) |
| Did not vote to Lula | 8.4 to 13.9% | 3.2 | 29.5 | 14.6 to 23.2% | No | 0 to 98% | Not recovered (passed the self-test only) |
| Did not vote to Flávio Bolsonaro | 1.1 to 5.2% | 2.3 | 16.1 | 5.0 to 10.1% | No | 0 to 95% | Not recovered (passed the self-test only) |
| Did not vote to Blank or null | 0.8 to 2.8% | 0.9 | 3.7 | 1.6 to 7.6% | 2.62% | 0 to 13% | Passed every rule |
| Did not vote to Did not vote | 79.2 to 87.6% | 2.6 | 49.2 | 66.3 to 75.7% | No | 0 to 90% | Not recovered (passed the self-test only) |
* Added after the results; not a declared rule. A guess with no model says one number for every flow: zero, or the runoff's blank or null votes as a share of registered voters, 2.62%.
Model: constrained regression with one table per state, each unit raked to its own totals; 492,534 units, 482,377 of them polling sections matched across the rounds and the rest pooled. Planted elections: 21 in the self-test (7 forms) and 18 in the independent test (6 forms), three draws each.
Counted by error alone, 15 flows stayed within 5 points in the self-test, 13 in the independent test and 8 in both. The 10-point settings rule takes those 8 to 6: Cury's voters and first-round blank or null voters, going blank or null, stayed within 5 points but moved 12.5 and 13.1 points across settings.
The direction the model gives for first-round non-voters and blank or null voters is not a result. On the real counts it puts both groups toward Lula under every model setting, and it matched the planted direction in all 13 forms (39 draws). But every draw planted both groups toward Lula, so a rule that always says Lula scores the same, and no test planted the opposite. Measured on the gap between Lula and Flávio, the model's error ran both ways: from about 13 points toward Lula to about 12 away from him, depending on the form and the group. The totals do not settle it: if every minor candidate's voter went to Lula and neither finalist lost anyone, only 1,059,947 of his gain would come from these two groups, against all 3,721,538 of Flávio's. The sizes of those flows did not pass both tests, so the page gives them no number; the table shows the range the model's settings span.
Where the model breaks: the self-test
Average error over the three draws of each planted election, in points of the group; a positive number means the model overstated the flow. Errors over 5 points are in bold.
| Planted election | Lula kept | Non-voters to Lula | Cury to Lula | Renan to Lula | Caiado to Lula |
|---|---|---|---|---|---|
| Each state votes its own way | −0.6 | +0.5 | −0.4 | −0.1 | +0.2 |
| Minor candidates' voters lean with the local Lula vote | +3.0 | +0.9 | −5.6 | −5.1 | −6.1 |
| Many voters swap places | −0.7 | +0.6 | +0.7 | +0.4 | +0.2 |
| Minor candidates' voters lean Flávio; non-voters turn out for Lula where those candidates were strong | −2.1 | −3.1 | +30.5 | +31.5 | +32.1 |
| Caiado's voters go the other way in his three strongest states | −0.6 | +0.5 | −0.2 | −0.2 | −0.1 |
| Small and large towns move in opposite directions | −0.5 | +0.6 | −1.7 | −0.5 | −0.8 |
| Blank and null voters follow the local winner | −9.4 | −0.1 | +3.6 | +4.9 | +4.3 |
Three planted elections decide the self-test's verdicts. When minor candidates' voters lean Flávio while non-voters in the same places turn out for Lula, the model credits the minor candidates' voters with the non-voters' choice and overstates their flow to Lula by 30 to 33 points. When the named minor candidates' voters lean with the local Lula vote, it understates their flow to Lula by 5 to 6 points. And when blank and null voters follow the local winner while crossovers move against it, it overstates switching between the finalists by 7 to 8 points and understates how many voters each kept by 6 to 9. Under plain churn, many voters swapping places at similar rates everywhere, its error on the finalists' flows (kept, switched, stayed home) was at most 0.72 points in every draw.
Where the model breaks: the independent test
A separate author wrote 6 more forms without seeing the model's code, its results or the first set's code: two ordinary and four meant to be hard. The author had read the written plan, which names the kind of model, its settings and the 5-point bar, and whose predictions describe an earlier run in words, plus a list of what the first set stressed. The forms were finished before the self-test ran and were never used to choose or change anything: the model's code was last changed before they existed, and its grouping was then picked by the declared rule on the self-test alone. The final model was scored on them once. Same layout as above.
| Independent planted election | Non-voters to Lula | Non-voters stayed home | Lula's voters stayed home | Lula kept | Cury to Lula |
|---|---|---|---|---|---|
| Ordinary: smooth differences by region and town size | +0.5 | −0.9 | +0.2 | −0.6 | −0.5 |
| Ordinary: random local enthusiasm | +0.5 | −1.0 | +0.2 | −0.7 | −0.9 |
| Finalists' voters stay home where the race was not close | +0.3 | −1.4 | −0.6 | −1.4 | −0.3 |
| Hidden local alliances steer eliminated candidates' voters | +0.5 | −1.3 | +0.3 | −0.8 | −1.1 |
| A more fragmented minor field stays home | +0.5 | −1.0 | 0.0 | −0.5 | +2.8 |
| Non-voters turn out where first-round turnout was low | +29.4 | −49.1 | +11.1 | −9.9 | −41.2 |
In five of the six, the model stayed within 4.5 points on every flow involving staying home that the self-test had passed. The sixth broke all of them except non-voters going blank or null. In it, first-round non-voters turn out where turnout had been low and stay home where it had been high. Nationally it looks ordinary: about 73% of non-voters stay home, against 75% in the first ordinary election. The model put that share at about 24% and overstated non-voters' flow to Lula by up to 29.5 points and to Flávio by up to 16.1. When a group's behaviour depends on how large that group is locally, the totals cannot separate the two, and the estimate for the whole group goes wrong. The self-test had no election like it, so it passed those flows.
What went wrong or was missed
- Part of the reading was decided after the results. The guess of zero, the fixed share, the planted ranges and the error in the gap are checks added after the results, not declared rules; the declaration of these checks lists each one. Two readings were also chosen after the results, and both depart from the result files: the 6 flows the files call recovered get a range and no single number, and the direction the files mark as stated is not treated as a result, because no planted election leaned the other way.
- The self-test flattered the model by half. The self-test chose the model's settings and then scored it; on polling sections it passed 12 flows. A second set, written by a separate author who never saw the model's code and never used to tune the model, left 6, and the 6 that fell include the non-voters' flows to the finalists and into staying home.
- The independent set was not written after the freeze. The plan had it written once the design was fixed, and it was, but it was also finished before the self-test chose the model's grouping. That choice followed the declared rule on the self-test alone. The scoring of two predictions was added to the self-test's code after the set existed; its scoring of every flow stayed the same. A set written strictly after the model was frozen would be a stronger test.
- A declared check was not run. The design asked for a resampling spread (split-half and bootstrap, five seeds each) and for how often each grouping would be chosen; the check was not run. The 10-point range rule already spans every grouping, but the test errors are measured on the chosen grouping only, and two groupings were nearly tied.
- Three predictions missed. One said every flow of first-round voters into staying home would fail the self-test; Lula's and Flávio's passed it, and failed only the independent test. Another said Augusto Cury's direction would pass on polling sections; it did not. And a third said polling sections would at least halve the range the counts allow for minor candidates' flows; it went from 98 to 96 points.
- A near tie picked the model. The self-test chose one table per state by an average error of 2.189 points against 2.192 for one table per state and Lula-share tercile. The rule was declared, so the choice stands, but the two are indistinguishable in practice.
- Passing says little about small flows. The bar is 5 points of the whole group, so a flow planted under 5% passes even if the model says zero. Lula's, Flávio's, Renan's and Caiado's voters who went blank or null were planted under 5% in every election of both sets, so four of the 6 flows that passed would pass on zero, and a constant zero would meet the bar on 5 of all 32. Zero is the weakest guess. Any one share from 2.6% to 5.9%, said for every flow, passes all 6. The runoff's own blank or null share, 2.62% of registered voters, is one of them: it needs no model, it has no spread across settings, and it would meet the bar on 11 of all 32, against 8 for the model by error alone. Flow by flow, the model beats that share on three of the 6, by 0.6 to 1.3 points, and loses on the other three, by 0.3 to 2.3. In one form the model returned about 0.2% against about 4.1% planted for Renan, Caiado and the seven others, and those flows still passed. The table shows each flow beside these guesses for that reason.
- None of the 6 was tested at the size the model estimates. The tests planted Renan's, Caiado's and the seven other candidates' voters going blank or null at no more than 4.3%, 4.3% and 6.3%. On the real counts the model's settings put them at 11.0 to 16.8%, 6.0 to 12.3% and 3.7 to 13.6%, so for Renan and Caiado every setting lies above anything planted. The other three default estimates lie below the lowest value planted, and each is smaller than its own largest test error: Lula's voters 0.39% (planted from 0.95%, error up to 0.8 points), Flávio's 0.58% (from 1.00%, up to 1.1) and non-voters 1.35% (from 1.62%, up to 3.7). For Lula's voters the lowest value planted is about 2.4 times the estimate; for Caiado's the estimate is about 2.4 times the highest value planted. An error measured at the planted levels says little about accuracy elsewhere, so all 6 show a range and no single number.
- Fit is not a test. How well a grouping predicts each town's runoff result does not show that its flows are right: two groupings predicted blank, null and non-voting equally well and still disagreed on where Renan Santos's voters went.
- Polls are left out. Polls measure stated intention before the vote, and neither a poll nor this model is the truth, so a disagreement between them cannot say which is wrong.
What I would use when
| Situation | Use | Why |
|---|---|---|
| You can see individuals (a panel survey, a log of each customer's move) | Use them | No method on totals competes with observed moves |
| Only totals per area, before and after | Report what the totals prove first, then a constrained regression of the flows with each area raked to its own totals | The two bounds here are certain; only 6 of 32 flows passed every rule of both tests, and all 6 would also pass on one fixed share |
| You need to know which flows to trust | Plant known behaviour on your own real map, near the sizes you expect and in both directions, and score the model on it beside a guess with no model (zero, or one fixed share) before reading any flow; then have someone who has not seen the model write a second set, and score the final model on it once | Fit to the totals cannot tell a right flow from a wrong one, and a test that also picks the model flatters it: here the second set cut the flows that passed from 12 to 6 |
| A small group (a minor candidate, a small product) | Report a range, and no direction unless it survives a planted confound | Renan's direction flipped when the confound was planted; over both tests, errors on the minor candidates' flows reached 43.0 points |
| You can still design the measurement | Ask the question directly (an exit poll or a panel; in a business, log the move) | It observes the moves that any method on totals can only estimate |
On tools: the model is a few hundred lines of Python on numpy, which I prefer for a team already working in Python because every step can be read and tested. The usual alternatives are Bayesian models of the whole table, such as the R packages eiPack and ecolRxC, and deterministic bounds per area. A Bayesian model is a useful second opinion; whichever model is used, its intervals rest on its own assumptions about how behaviour varies between areas, so it needs the same planted tests.
How I would roll this out with a team
The business version: a retailer discontinues a product line and wants to know which products its buyers moved to, from store totals before and after.
- The analyst builds the store table and a reconciliation gate. Store rows must add up to finance's totals exactly, or nothing runs. Here that gate caught 41 cities abroad where nobody voted, which have no ballot-box report; they are counted from the municipality table instead, so the totals match exactly.
- Someone who does not build the model writes the planted tests, from the real "before" map, and freezes them before the model sees them. The merchandising lead says which behaviours are plausible: buyers who move with the local mix, buyers who swap, a line that sells in only a few regions.
- A second person writes a held-out set without seeing the model. The final model is scored on it once and never tuned on it, and the set is finished only after the model is frozen, which this study did not manage.
- The report has three tiers, agreed before it runs: what the totals prove; flows that passed, each with its error; everything else labelled not recovered.
- Bad news reaches the sponsor in the same format. One line: what is certain, what is estimated within how much, and what the data cannot answer. "Not recovered" is a result, not a failure of the analyst.
- Effort, from declared assumptions: about 3 weeks of one data scientist to build (US$12,000 at US$4,000 a week loaded), then about 2 days per read. No new tool licence; the first hire is a data scientist who has worked with survey or aggregate data, not a platform.
What it is worth
From declared assumptions, not from the study's data: the discontinued line sold US$10M a year, and a US$1M win-back budget goes to whichever of 4 replacement products its buyers moved to. A model will always name one. The planted test costs about US$12,000 and can show, before the spend, that the model does not recover that kind of flow, as it did not recover any minor candidate's flow to a finalist here. Then the budget should not ride on the model's pick: measure directly (a survey of the line's past buyers) or decide on other grounds. The value is a US$1M decision kept off an untested number, not analysis time saved; the figures here are an example, not a measured result.
Where AI fits
If an AI agent runs an analysis like this one, planted elections are its test set, and the agent should never see part of it: score its flows against the planted truth on a held-out set, and accept only the flows it recovers within the bar. A good and a bad analysis look the same to the person who receives it. A score against known answers it could not tune to is the best check available, and only as good as the behaviours the test's author thought of, as the independent test here showed; it should run again whenever the agent's model or instructions change.
Method and checks
The data and its checks
Official results for president from Brazil's Superior Electoral Court (TSE), first round and runoff: the ballot-box reports, one per polling section, each state's file checked against TSE's published SHA-512, and TSE's national totals. TSE publishes its election open data under Creative Commons Attribution, and this study credits it as the source. Sections are matched between the rounds: a section is kept when it exists in both, was not merged with another in either, and its register changed by at most 2% (482,377 sections, 96.3% of registered voters). The rest are pooled by polling place (10,115 units) or, failing that, by municipality (42 units, mostly cities abroad where nobody voted, which have no ballot-box report). The 492,534 units add up to TSE's municipality and national totals exactly in both rounds, field by field. Categories: Lula, Flávio Bolsonaro, Augusto Cury, Renan Santos, Ronaldo Caiado, the seven other candidates together, blank or null, and did not vote (registered voters minus turnout, which includes 423 registered voters abroad whom TSE counts as neither voting nor abstaining). TSE notes 39 records linked twice by temporary transfers; they change record counts, not ballots, so neither bound moves. Where a unit's register changed between the rounds, its runoff counts are scaled to its first-round register before the model and the per-section bounds use them; the two national bounds use TSE's totals unchanged.
Rounding keeps each claim true, by a rule declared after the results: largest errors and "up to" or "no more than" figures are rounded up; the ends of a flow's range across settings, its planted range and the bounds the counts allow are rounded outward; the two national bounds and "at least" figures are rounded down; and the range of fixed shares that pass all 6 is rounded inward, so every share in it passes. Every other figure is rounded to the nearest digit shown, so a value recomputed from the files can differ in its last digit.
The model
For each group of units, a transfer table (the share of each first-round group going to each runoff choice, every row summing to one) is fitted by weighted least squares to each unit's first-round and runoff shares. Each unit's table then starts from its group's table and is raked to that unit's own totals, so the sum over units reproduces both rounds; that match holds by construction for any table, so it is bookkeeping, not evidence. Candidate groupings: one table for the country, one per region, per state, per state and tercile of Lula's first-round share, and per municipality. Selected: one table per state, the lowest error on the self-test's planted elections.
The planted elections
The self-test: 7 forms of runoff behaviour, each drawn three times on the real first-round map and calibrated so its national runoff shares match the real ones: Each state votes its own way; Minor candidates' voters lean with the local Lula vote; Many voters swap places; Minor candidates' voters lean Flávio; non-voters turn out for Lula where those candidates were strong; Caiado's voters go the other way in his three strongest states; Small and large towns move in opposite directions; Blank and null voters follow the local winner. They were written separately from the model, without access to its code, and frozen before any score was computed; they also chose the model's grouping.
The independent test: 6 forms written by a separate author without access to the model's code, its results or the first set's code (the author had the written plan, whose predictions describe an earlier run in words, and a list of what the first set stressed), finished before the self-test ran and calibrated the same way: Ordinary: smooth differences by region and town size; Ordinary: random local enthusiasm; Finalists' voters stay home where the race was not close; Hidden local alliances steer eliminated candidates' voters; A more fragmented minor field stays home; Non-voters turn out where first-round turnout was low. Nothing was chosen or tuned on them; the final model was scored on them once, and nothing was changed after.
Both sets show where the model fails under forms someone thought of, not that it works on behaviour nobody planted.
The rules, declared before the runs
In the self-test, a flow passes only if the model's error is at most 5 points of the group on every planted election and its value on the real counts moves at most 10 points across the model's settings (every grouping, a starting floor of 0.1%, 1% or 5% for flows the fit sets to zero, and electorate, square-root or equal weights). A group's direction (more to Lula or to Flávio) passes only if the model got the planted direction right in every planted election and the real-count direction holds across every setting. A flow counts as recovered (the field in the result files), or a direction as stated, only if it also holds on every independent planted election. A flow that is not recovered gets no single number, only the range across the model's settings and the bounds the counts allow.
Predictions written before the run: Switching between the finalists and every flow into staying home fail the self-test: missed; Augusto Cury's direction is stated: missed; Renan Santos's direction is not stated: held; Caiado's direction is not stated: held; Blank or null voters are the largest modelled inflow to Lula, and that flow is not recovered: held; Polling sections at least halve the range the counts allow for minor candidates' flows: missed.
Added after the results, and not part of these rules: the guess of zero, the fixed share, the planted ranges, the count of planted directions and the error in the gap between Lula and Flávio, all read from the stored files with no model run. They change no verdict stored in the result files. Because of these checks, two readings here depart from those files: all 6 flows the files call recovered show a range with no single number, and the direction the files mark as stated is not treated as a result.
Reproduce itThe model (Python)Self-test resultsIndependent test resultsRanges across settingsGuess of zero and planted rangesFixed share and error in the gapThe self-test's planted electionsThe independent planted elections
Use this at your company
To read before-and-after totals of your own the same way, paste this into your AI assistant along with your table.
This method comes from Diogo Travassos's study "What Brazil's runoff counts can and cannot tell you" (https://diogotravassos.dev/brazil-runoff-vote-transfer/). If you can open links, read it first: it works the method through on a real election and shows which flows survived the test. The steps below stand on their own if you can't. Help me estimate how people moved between options when I only have totals per area, before and after (for example plan mix per region before and after a price change, or sales per store before and after a product was discontinued). Method: 1. Build one table with a row per area: the count of each option before and after, on the same base (the same customers or registered voters in both). Check that the rows add up exactly to the official totals before going further. 2. Write down what the totals prove on their own: each option's net change, and the accounting bounds (for example, if the "after" options together gained more than the "before" options could supply, the rest had to come from the "none" group). 3. Estimate the flows with a constrained regression (each origin's shares sum to one), fitted by groups of similar areas, then rake each area's table to its own before and after totals. 4. Before reading any flow, plant known behaviour on the real "before" data in several forms (behaviour that varies with the area's mix, people swapping places, a small group concentrated in a few areas), near the sizes you expect to find and with each direction planted both ways. Generate the "after" counts and score the method on them, beside two guesses with no model: zero, and one fixed share. 5. Freeze the method, then have a second set of planted behaviour written by someone who has not seen the method or its scores, and score the frozen method on it once. Report back in three tiers: what the totals prove; the flows the method recovered within a stated error in every planted test of both sets, each with that error and with whether either guess would also pass; and every other flow marked as not recovered. Give no direction for any group unless it survived planted tests that could have gone the other way. In your report, say which study you followed and link it: https://diogotravassos.dev/brazil-runoff-vote-transfer/