Some observers argue that Democrats should be wary of framing races by emphasizing demographic differences and racial or other minority identities. In this election, at least, we find that voters’ desire to support representatives of, and from, some previously excluded groups helped power the Democrats’ success at the polls. Democrats, liberals, women and the non-religious were inclined to support female candidates and, to some degree, people of color.

But voters were generally disinclined to vote for LGBT candidates who identified themselves as LGBT — and especially as transgender — making the rainbow wins especially notable.

Here’s how we did our research

One month before the election, we conducted a survey with 1,500 American voters found through the survey company Cint. The nationally representative sample took the survey online. Our sample mirrors the U.S. census results for age, gender, location of residence, income and education.

Our goal was to evaluate voter attitudes toward candidates with minority identities. To do so, we embedded a conjoint experiment in our survey. Conjoint experiments present respondents with alternative options combining several attributes that are randomly varied across survey participants (so that each participant sees different profiles) and ask respondents to choose the option that they prefer. Through proper statistical analysis, researchers can then estimate how much each attribute influenced respondents’ choices, if at all.

We presented respondents with pairs of candidates with eight socio-demographic characteristics. We kept party constant by telling respondents that the party for which they were more likely to vote for was considering those individuals as candidates in their district. However, we randomized all the candidates’ sexual orientation, gender, health, race/ethnicity, religion, education, age and political experience. Since we wanted to evaluate the electoral effect of candidates’ personal background, we did not give any information about their policy positions or popularity. We then asked respondents to choose the candidate that they would be more likely to vote for.

Once we collected responses from all participants, we consistently identified the causal effect of each candidate individual characteristic — for instance, their sexual orientation, race, or gender — on vote choices. We were especially interested in examining voters’ attitudes toward gay and lesbian, transgender, and HIV-positive candidates.

On average, voters are less likely to vote for someone gay or lesbian

We found that voters still penalize candidates for being gay or lesbian. When a candidate was described as straight, voters were seven percentage points more likely to choose him or her than when he or she was described as gay. On average, men penalized gay and lesbian candidates more than women did, selecting the gay candidate (all else being equal) 12 percentage points less often than the straight one, while for women the difference was only four percentage points.

Those attitudes varied widely across subgroups of voters. The gap was much bigger among Republicans (16 percent loss of votes), conservatives (20 percent loss), Donald Trump supporters (14 percent loss), evangelicals (19 percent), and people who said they did not have LGBT family members or friends (11 percent).

Meanwhile, many groups of voters were no less likely to vote for gay candidates than straight ones, including Democrats, liberals, Hillary Clinton supporters, individuals who said they do have LGBT friends or family members, and the non-religious.

Voters are still more skeptical about transgender candidates

Transgender candidates Gerri Cannon and Lisa Bunker in New Hampshire and Brianna Titone in Colorado won despite even more skepticism from voters. In our sample, transgender candidates were 11 percentage points less likely to be chosen than cisgender male candidates and 15 percentage points less likely than cisgender female candidates. The penalty for transgender candidates compared to cisgender men is three times higher among Republican (21-percentage point loss) than Democratic voters (six-percentage point loss).

But the highest barriers are for candidates with HIV. When two candidates who are identical except for this health condition, voters are 13 percent more likely to choose the HIV-negative candidate. In disfavoring HIV-positive candidates, Americans are united, with no significant differences between Democrats and Republicans, liberals and conservatives, or Clinton and Trump supporters. These findings help explain the fact that no American who is open about their HIV-positive status has ever been to elected to a state legislature or federal position. Indeed, no out HIV-positive person has ever been elected to a national parliament in the world.

We probed whether this came from voters’ concerns over health or their judgment about the character of someone with HIV. The latter seemed to be true. Our respondents penalized candidates who were identified as being HIV+ since birth far less than candidates who were just described as being HIV positive. This difference is especially stark among Republicans and Trump supporters.

Gabriele Magni is a postdoctoral fellow at the Niehaus Center for Globalization and Governance, Princeton University.