Sometimes, as the time-worn sports adage goes, it’s better to be lucky than good.

In the wake of the 2012 Senate elections, a number of Republicans were probably murmuring that phrase under their breath. Democrats had netted two seats in the upper chamber, partially because Republican candidates in two red states had made serious gaffes about abortion. Todd Akin of Missouri, who was challenging Democratic Sen. Claire McCaskill, said that a woman’s body could “shut down” a pregnancy in occurrences of “legitimate rape.” Richard Mourdock lost to Democratic Rep. Joe Donnelly in Indiana after saying that the pregnancy of a woman who had been raped was “something that God intended to happen.”

In that way, McCaskill and Donnelly both got lucky -- every candidate prays daily that their opponent makes damaging missteps. But were these Democrats just lucky, or were they also good? Put differently, is there evidence that they have some strength or advantage that would have allowed them to win (or at least run better than a generic Democrat) even if their opponents hadn’t made those statements?

This might seem like a dated or pointless question, but both senators are up for re-election in 2018 and assessing their appeal is a key part of gauging their chances of winning. For Donnelly, the answer seems to be yes (I’ll address the same question regarding McCaskill in a later piece). Evidence from polling and election results suggests there was more to Donnelly’s win than a mistake by his opponent.

The Race Was Close Before Mourdock’s Abortion Comments

While Mourdock’s comments likely helped Donnelly in 2012, surveys show that the race was always close. Polls are somewhat sparse due to an Indiana law that makes polling more expensive, but I was able to divide the data we do have into two groups -- polls before and after Mourdock’s comments. Before the controversial remarks, the polls showed a tight race. Both candidates led in various surveys, and neither one built a sizable lead at any time.

After Mourdock’s gaffe, pollsters flocked to Indiana and found Donnelly’s support increasing quickly. The final polls showed a slight edge for the Democrat, and he ended up winning by six points.

Obviously, someone could object to this narrative (public polling was limited; campaign pollsters might have had a different view of the race based on internal polls, etc.), but it shows that Donnelly’s win likely wasn’t built solely on Mourdock’s abortion comments. Indiana had a Cook PVI of R+6 heading into the 2012 election (meaning that it leans six points more Republican than the nation as a whole), so the fact that Donnelly was close before those remarks shows that either he was a good candidate or that Mourdock was problematic in other ways.

Donnelly’s Map Wasn’t a Simple Reaction to Events

The map of how Donnelly won also suggests that factors other than Mourdock’s abortion remarks were at play. To see this, I’m going to compare two different races – Barack Obama’s 2008 win in Indiana and Donnelly’s 2012 win -- to Obama’s 2012 performance in the state.

In 2008, Obama won Indiana by one percentage point -- his second thinnest margin in any state that year. The Illinois senator wasn’t a perfect fit for Indiana, which has a small black population, an even smaller Hispanic population and a large number of rural and small-town voters. Modern Democrats typically lose a state like this. Obama lost there by 10 points in 2012 and Hillary Clinton lost by 19 (it’s worth noting that former Indiana Gov. Mike Pence’s presence on the Republican ticket might have increased Donald Trump’s 2016 margin somewhat).

In other words, Obama didn’t win in Indiana on personal appeal alone -- he was likely helped by the broader national circumstances. Under President George W. Bush, the situation in Afghanistan had deteriorated and the financial system had crashed, leading to one of the greatest economic downturns in American history. That led many swing voters and Republicans to cast their ballot for the Democratic nominee.

So the difference between Obama’s 2008 and 2012 performance might, to some degree, show which voters would swing towards a generic Democrat if the Republican was, for some reason, unacceptable.

The areas where Donnelly outperformed Obama in 2012 overlaps with these areas, but the map is somewhat different. (In the first graphic, darker shades of green correspond to greater over-performances by Obama in 2008 compared to 2012. In the second graphic, the color scheme is similar -- Donnelly's vote share outpaced Obama's 2012 share by greater amounts in the darker areas.)

Statistically speaking, the difference between Obama’s 2008 and 2012 performance explains about a third of what’s going on in the Donnelly map. In fact, after controlling for the difference between Obama’s two showings, we see that Trump’s vote share in the primary, the percentage of voters who were born in state in each county, and the rate of college education among whites were all statistically significant predictors of where Donnelly outperformed Obama in 2012.

There’s two ways to interpret this data. It’s possible that there’s nothing special about Donnelly -- that is, that voters just responded differently to a different type of “crisis.” Bush’s failings at home and abroad drove some voters to Obama, and Mourdock’s comments sent a slightly different set of voters across the aisle.

But I think it’s more likely that the latter map reflects some of Donnelly’s personal appeal. Donnelly identifies as pro-life, supported the Keystone XL pipeline and opposed President Obama’s executive action on immigration (thought he supported a 2013 immigration reform effort). It’s difficult to disentangle the effects of Mourdock’s remarks, his overall conservatism and Donnelly’s personal brand from how each part of the state voted in 2012. But it’s not hard to think, based on this data, that Donnelly’s persona and reputation allowed him to build a slightly different and arguably larger base than recent Democratic presidential candidates have.

So Maybe It Wasn’t Just Luck

None of this means Donnelly will win next year. It’s possible that he could draw a more formidable challenger than Mourdock, and maybe some of the recent changes to the political landscape make it nearly impossible for a Democrat to win in the Hoosier State. Moreover, it’s impossible to know what the political climate will be like in 2018. If Trump’s approval improves, Donnelly’s re-election chances decrease, just as they increase if Trump’s poll numbers fall.

But the evidence suggests that Donnelly wasn’t just fortunate. He caught some lucky breaks (not everyone gets an opponent who stumbles in the way Mourdock did) but there are signs that some of his strength also comes from skill.