When building a statistical model, you ideally want to find yourself surprised by the data some of the time — just not too often. If you never come up with a result that surprises you, it generally means that you didn’t spend a lot of time actually looking at the data; instead, you just imparted your assumptions onto your analysis and engaged in a fancy form of confirmation bias. If you’re constantly surprised, on the other hand, more often than not that means your model is buggy or you don’t know the field well enough; a lot of the “surprises” are really just mistakes.

So when I build election forecasts for FiveThirtyEight, I’m usually not surprised by the outcomes they spit out — unless they’re so surprising (a Republican winning Washington, D.C.?) that they reflect a coding error I need to fix. But there are exceptions, and one of them came in the U.S. Senate race in Texas between Republican incumbent Ted Cruz and Democratic U.S. Rep. Beto O’Rourke. I was pretty sure that once we introduced non-polling factors into the model — what we call the “fundamentals” — they’d shift our forecast toward Cruz, just as they did for Marsha Blackburn, the Republican candidate in Tennessee. That’s not what happened, however. Instead, although Cruz is narrowly ahead in the polls right now, the fundamentals slightly helped O’Rourke. Our model thinks that Texas “should” be a competitive race and believes the close polling there is no fluke.

We’ll return to Texas in a moment, but first, here’s a table comparing the polls and fundamentals in the five Senate races where elected Republican incumbents are defending their seats. (We covered races with elected Democratic incumbents in Part 1 of this series and open-seat races in Part 2). As you can see, there isn’t really a lot of disagreement between the polls and fundamentals in these races:

Republican incumbents are polling about as well as expected Forecasted margin of victory for Republican senators who are running for re-election, according to FiveThirtyEight’s fundamentals and adjusted polls as of Sept. 26 Forecasted margin of victory Race Incumbent Fundamentals Adjusted Polls Nevada Heller -0.5 -0.9 Texas Cruz -0.3 +3.8 Nebraska Fischer +15.1 +13.0 Mississippi Wicker +19.2 +16.6 Wyoming Barrasso +40.8 — The Mississippi special election is not listed because Sen. Cindy Hyde-Smith is an appointed rather than an elected incumbent and our model treats races with appointed incumbents as open-seat races. There has been no polling of the Senate races in Wyoming.

I’m not going to discuss Nebraska, Wyoming or the regular election in Mississippi much further. You wouldn’t expect them to be competitive based on the fundamentals, and they haven’t looked competitive when polls have been taken there — although I wouldn’t mind seeing a poll of Nebraska, which hasn’t had a nonpartisan survey all election cycle or any polling at all since January.

I would note, however, that our fundamentals calculation doesn’t expect all Republican incumbents to be in competitive races just as a default — it has Nebraska Sen. Deb Fischer winning by 14 percentage points and Wyoming Sen. John Barrasso winning by 41, for example. Rather, it’s factors particular to Texas that make the model think Cruz is a weaker incumbent and O’Rourke is a stronger challenger than usual. So let’s talk about Texas in more detail, and then we’ll loop back around to the other close race, Nevada.

Before this year, we treated incumbency as just another variable in our fundamentals model. That was a mistake, because there are all sorts of complicated interactions between incumbency and the other variables that go into the fundamentals. To take an obvious example, the margin of victory in a state or district’s previous election is a lot more meaningful when there’s an incumbent running than when there are two new candidates on the ballot.

So this year, we built separate fundamentals models for races with elected incumbents, compared with open-seat races. One of the most important differences is that a state or district’s overall partisanship, as measured by voting in elections for president or state legislature, is less important in races with incumbents. Something like presidential voting is a very useful indicator when you don’t have a lot of other data to go by. But in races with incumbents, we have a lot of information pertinent to the specific incumbent and his or her strengths. For instance, our fundamentals calculation for Florida’s 26th Congressional District knows that Republican Carlos Curbelo won the district by 12 points in 2016 even as the area voted overwhelmingly for Hillary Clinton for president. That doesn’t necessarily mean that Curbelo will survive the “blue wave” this year. (He’s only a slight favorite for re-election.) But it does mean the presidential vote doesn’t tell you everything you need to know about the district

Cruz, on the other hand, shows signs of being a weak incumbent — and O’Rourke shows signs of being a tough challenger. Here’s a detailed calculation of exactly what goes into the fundamentals model in Texas.

Some factors hurting Cruz have nothing to do with Cruz himself, but rather with the state of Texas. Historically, the incumbency advantage is larger in small, idiosyncratic states and smaller in larger, more diverse ones. This is why Democratic Sen. Mazie Hirono’s incumbency advantage in Hawaii is much larger than Cruz’s in Texas or Sen. Bill Nelson’s in Florida, for example. In addition, Congress’s overall approval rating is low, which hurts incumbents in all states and all parties.

Still, Texas is a red state — redder in statewide elections than in presidential ones, in fact — and Cruz won by a fairly healthy (although by no means overwhelming) margin in 2012. That ought to be enough to offset a blue national environment as measured by the generic congressional ballot. If you add up the first four indicators in the table — incumbency, state partisanship, Cruz’s previous margin of victory and the generic ballot — they’d project him to win by about 9 percentage points.

It’s the other factors that push the race toward toss-up status, however. When a challenger has previously held an elected office, they tend to perform better with each level higher that office is. To run for Senate, O’Rourke is giving up his seat in the U.S. House, which is a higher office than had been held by Cruz’s 2012 opponent, Paul Sadler, a former state representative. Strong incumbents tend to deter strong challengers from entering the race, but Cruz wasn’t able to do so this time. Cruz also has a very conservative voting record, one that is perhaps “too conservative” even for Texas. The model actually penalizes O’Rourke slightly for his DUI scandal, but because the scandal has been public knowledge for a long time, the model discounts its importance.

Fundraising is another influential factor hurting Cruz. Ordinarily, you’d expect an incumbent to have a pretty healthy fundraising advantage. Instead, O’Rourke had more than doubled Cruz in dollars raised from individual contributors as of the end of the last filing period on June 30 — an advantage that will probably only increase once the campaigns file their next fundraising reports, which will cover up through Sept. 30. (Our model considers money raised from individual contributors only — not PACs, parties or self-funding.) If fundraising were even, Cruz would still lead in our fundamentals calculation by 4 percentage points, but O’Rourke’s money advantage is enough to bring the overall fundamentals forecast to a dead heat.

One could get into some pretty good arguments about exactly how fundraising should be included in the model. Should out-of-state or out-of-district contributions get less weight, for example? Are Republican donors contributing less in the post-Citizens United era because they expect super PACs to fill in the gaps for them? Still, individual fundraising totals have one really nice quality, which is that they represent hard evidence — tangible action undertaken by individual voters. If you thought you could never trust the polls, fundraising might be one of the first things you’d look at instead. And the fundraising numbers have generally been really good for Democrats, in Texas and in other races for Congress, perhaps reflecting their enthusiasm advantage.

Now that you’ve read all those words explaining why the fundamentals look the way they do in Texas, I should probably tell you that they don’t actually have that much influence on our top-line forecast there. That’s because a lot of polling has been done in Texas, and our model doesn’t weigh the fundamentals heavily when it has a lot of polling. Nonetheless, the fundamentals help explain why it isn’t necessarily a surprise that the polling shows a close race in Texas or that O’Rourke has gradually been gaining ground. At the moment, Cruz leads in our adjusted polling average by 3.8 percentage points; adding in the fundamentals pushes the forecasted margin to 3.3 points, a close race.

Let me also show you the detailed fundamentals calculation for Nevada, which is a more straightforward race:

Republican Sen. Dean Heller is a fairly typical incumbent who should have a decent-sized incumbency advantage, and Nevada is a fairly average swing state. He’s drawn an experienced opponent in U.S. Rep. Jacky Rosen, however, who has raised slightly more money than Heller has — and the overall political environment is blue. All of that adds up to a race that “should” be a toss-up, which is exactly what the polls in Nevada show too. Nevada may not be as high-profile a race as Texas, but it’s just as important in determining control of the Senate.