In the time since House Majority Leader Eric Cantor was defeated in the Republican primary for Virginia’s 7th Congressional District, conventional wisdom has coalesced around an explanation for the upset: Cantor’s relatively moderate stance on immigration reform. We’re generally skeptical of quickly formed ex post facto explanations, so I looked into how big a factor immigration has been in Republican primaries.

Bigger than I thought, perhaps. Immigration reform either matters by itself or is a good proxy for where a candidate falls on the establishment-antiestablishment spectrum.

Public opinion surveys, such as the one Public Policy Polling conducted Tuesday night in Cantor’s district, have found that immigration reform is relatively popular among Republican voters. But because those surveys don’t attach President Obama’s name to the issue, they probably overestimate support among Republicans, as Mark Blumenthal and Ariel Edwards-Levy pointed out at HuffPollster.

We can, however, test whether immigration-reform-friendly Republicans do better or worse in primaries than their counterparts. To approximate support for an immigration overhaul, I used immigration scorecards issued by NumbersUSA, a group that advocates “for lower immigration levels.” Higher scores indicate that a politician supported actions more in line with NumbersUSA’s goals — an imperfect indication of being against immigration reform. Because of redistricting and the difficulty of collecting data for House members, we’re going to concentrate on senators in office during the Obama administration.

Looking at the performance of senators who faced primaries, we found that those with higher antireform scores do better in primaries.

But this might reflect the partisan tilt of each state, so let’s control for Obama’s vote in the district. (We’re about to get real nerdy here; if math makes your head hurt, skip down a little.)

Although the importance of p-values can be overstated, we see the immigration score is both statistically significant — see the p-value (“P>t”), less than 0.05 is good — and substantively significant (see the coefficient for “immig,” further away from zero means there’s more of a relationship).

We can also look at the same effects when controlling for: 1) the overall ideology of each senator, and 2) the insider-outsider status of each senator. Using the DW-Nominate system, in which higher values of the first dimension are associated with a more conservative voting record (see my piece Tuesday night for a more in-depth explanation of DW-Nominate), we see that the immigration score maintains its significance.

The ideology variable, “dwn_1,” is related but not significant, as is the second dimension for insider-outsider status, “dwn_2.”

You’ll note the coefficients on the DW-Nominate scores are the opposite of what they were Tuesday night. For example, the ideological variables indicates that senators who are more conservative do worse in the primaries. But we shouldn’t take that seriously. We may be dealing with a multi-collinearity problem — when the independent variables we’re looking at are closely correlated. Look at how well the immigration scores are predicted by the ideological and insider-outsider scores (see the coefficients):

It’s no wonder that past incumbents who lost in a convention or primary tended to have low immigration and general ideological scores. According to NumbersUSA, Utah’s Bob Bennett had a C-, Indiana’s Dick Lugar had a D- and Alaska’s Lisa Murkowski had a D+ on immigration. Those all match their low DW-Nominate scores.

Ok, non-math readers: Please join us again.

We’re left with at least three possible explanations for why immigration scores are tied to incumbent Republican’s primary performance.

Republicans do worse when embracing immigration reform — the issue itself matters. That’s certainly what the people at NumbersUSA want people to think, and that’s been the general media narrative. The problem with that theory is Republican Sen. Lindsey Graham, who won his South Carolina primary, has been pro-reform. On the other hand, Graham only got 56 percent of the vote. It could be, as the Pew Research Center pointed out, that immigration was “a symbol of a larger concern among some Republicans about the direction of the nation.” Cantor’s opponent, David Brat, said immigration was “the most symbolic issue that captures the difference between myself and Eric Cantor.” Maybe voters aren’t overly concerned about immigration but use it to divide candidates they like from those they don’t. This would be an argument for candidates spending more time in their district, explaining their views to ensure that politicians don’t fall into the symbolic trap. The least sexy answer is that we’re dealing with a confounding variable. Correlation does not equal causation, and immigration reform may be a proxy for ideology in a way that DW-Nominate scores cannot pick up . It would certainly explain why they are so related to each other.

We can’t be sure exactly what role immigration played in Cantor’s defeat, but Republican incumbents’ stance on immigration has been predictive of their performance in primaries during the Obama era. This goes beyond just being “conservative” in the traditional sense. In GOP primaries, a Republican’s willingness to compromise on immigration probably appears to do them more harm than good.