It's the lashing-out theory of Trumpmania. President Obama, Sen. Bernie Sanders, and others have speculated that working class whites are signing on to Donald Trump and his inflammatory anti-immigrant rhetoric out of a deepening anxiety over their place in the 21st century American economy.

Some political scientists, however, say antagonism toward immigrants is being driven by a more primal instinct: mistrust of outsiders — or even racial prejudice, either of the conscious or unconscious variety.

A body of academic research has tried to deconstruct why some Americans are skeptical about immigrants. Are they driven by policy concerns, about economics, or security? A general dubiousness about foreigners? Or a deep-seated aversion to people of a different skin tone?

A study forthcoming in the journal Political Psychology sheds new light on these questions. Political scientist Mara Ostfeld, who will be an assistant professor at the University of Michigan, randomly assigned white, non-Hispanic people to read different fictional stories about an immigrant family.

In one version of the story, the immigrants are sitting at a diner eating buffalo wings and discussing baseball. In another, the immigrants are at an ethnic food market eating spicy goat meat and talking in their native tongue.

After seeing the stories, the people were asked broad questions about immigration policy.

People who read about the American-acting immigrants expressed more positive feelings about immigrants and immigration policy in general — they were more likely to believe immigrants are helping America, more likely to support increasing the number of immigrants, and less likely to support building a fence on the Mexican border.

In other words, Ostfeld showed that people’s attitudes about immigration can be nudged just by having them read stories about immigrants who behave in traditionally American ways.

These effects were modest, though statistically significant, and not too surprising. So far, these results were in line with past experiments showing that people feel positively toward immigrants who they think have made an effort to fit in.

Hidden fears 

Outfeld wanted to go deeper, though.

In previous studies, researchers have found that people's views on immigration policy are affected generally by the ethnicity of the immigrants being discussed, but they did not find an effect based on skin color. In other words, showing people pictures of darker-featured Latinos as opposed to lighter-featured Latinos doesn’t change how they feel about immigration policy.

In her experiment, Outfeld took another angle. After showing subjects pictures of either light-skinned or dark-skinned families, she also asked more personal questions. How would they feel having the immigrants from the story move into the neighborhood? Work alongside them? Marry somebody in the family?

On all these measures, respondents shown the darker-skinned immigrants were less likely to be accepting. Asked for their feelings about these scenarios a scale of 1 to 10, people given the darker pictures were about half a point less enthusiastic on average.

It's hard to detect racial prejudice in surveys because people tend to censor themselves when a stranger asks directly. But by comparing subjects who were randomly shown different pictures, Ostfeld got to measure people’s knee-jerk biases.

Ostfeld’s study shows that context matters to the immigration debate. “It’s really important we understand that our perceptions of threat are different, whether we’re thinking about immigration in the abstract or in our own communities,” she says.

When the discussion is about immigration policy in general, people are mostly concerned with way immigrants act, not the way they look. Will the newcomers fit in? Will they adopt American ways of life, or change what it means to be American? But if you get specific — if you talk about immigrants moving in next door — then people's racial biases also start coming to the fore.

The political implications

This issue has become particularly salient as immigration takes center stage in the GOP presidential primary. Trump has rallied supporters by inflaming their anxieties about immigrants, calling some Mexicans rapists and Syrian refugees terrorists. Trump's platform makes this a local issue, talking about the impact of immigration on "communities, schools and unemployment offices."

Earlier this month, the New York Times published data suggesting that the most racist places in America — where people tend to make the most “racially charged” Google searches — are often the same areas where Trump has the strongest support among conservatives.

Researchers have found that racism tends to predict anti-immigrant views. Public opinion surveys, for example, show that whites who hold negative stereotypes about blacks are also more likely to oppose immigration, and to support making English the official language of the United States. This is a “surprising” result, the authors note, because most immigrants these days are not black, but Latino or Asian.

While many have blamed economic stress for causing Trump voters to direct their anger at immigrants, these and other studies show that views against immigration are often guided by deeper instincts.

“In fact, the evidence suggests there’s more to the view that it’s all about culture — that people are threatened by different ways of life, different religions, and different languages,” says Shanto Iyengar, a political science professor at Stanford. “You have a bunch of other people speaking other languages, with brown skin, going to temples and mosques, and that is what is making people oppose immigration.”

Trump, Iyengar says, has been particularly enthusiastic at highlighting this cultural divide. The candidate scored points at a Republican debate in September when he scolded Jeb Bush for speaking Spanish on the campaign trail. “We have to have assimilation to have a country,” Trump later told Politico.

“[Trump] features all kinds of culturally dissimilar people in his rhetoric. He mentions specific nationalities, goes out of his way to point out this [immigration] is coming from a different country, a different way of life,” Iyengar says. “He is absolutely playing to this notion of assimilability.”

Many Americans seem to share the view that immigrants are dedicated to maintaining a different culture. A Pew poll in April, for instance, showed that 59 percent of the nation believes immigrants aren’t learning English fast enough, while 66 percent say that immigrants these days want to hold onto their customs instead of adopting American ones.

These beliefs aren't accurate. A massive report from the National Academies of Sciences, Engineering and Medicine has shown that today’s immigrants are integrating as swiftly as their predecessors, if not faster. They are more likely to speak English than past immigrants, are more educated, and neighborhoods with lots of immigrants tend to have less crime.

So why do so many Americans believe otherwise? Perhaps there is also some underlying bias, like what Ostfeld's research uncovered. Anxiety over immigrants not assimilating might not reflect racism per se, but it is influenced by a similar (and very human) impulse: suspicion of people who look and act differently. And sometimes, perhaps, a complaint about clashing cultures is really a complaint about race in disguise.

These sentiments have deep roots in America's past. In 1751, for instance, Benjamin Franklin griped about German settlers in Pennsylvania and their "swarthy" features, contrasting them to the "white" English. "Why should Pennsylvania, founded by the English, become a Colony of Aliens, who will shortly be so numerous as to Germanize us instead of our Anglifying them, and will never adopt our Language or Customs, any more than they can acquire our Complexion," Franklin wrote.

“But perhaps I am partial to the Complexion of my Country,” he added, “for such Kind of Partiality is natural to Mankind.”