Good neighbors can be a blessing, whether they’re people you can trust to water the plants or watch the kids. But building that trust can be hard: Just half of Americans (52%) say they trust all or most of their neighbors, while a similar share (48%) say they trust some or none of their neighbors, according to a 2015 Pew Research Center survey.

Not surprisingly, those who say they feel unsafe in their neighborhoods are less likely to trust their neighbors. Just 17% of respondents who feel “not at all safe” from crime when walking in their neighborhoods after dark say they trust all or most of their neighbors, compared with 71% of those who feel “very safe.” Urban residents – who are less likely than suburban or rural residents to say they feel very safe in their neighborhoods – are also less likely to say they trust all or most of their neighbors.

The demographic differences on neighborly trust are largely related to economic class, at a time of rising residential segregation by income. Our survey finds that Americans who can afford to live in more affluent neighborhoods are generally more trusting of their neighbors: 67% of those with household incomes of $75,000 or more say they trust all or most of their neighbors, compared with just 37% of those earning less than $30,000 per year.

But differences in neighborly trust aren’t just associated with economic class. For example, six-in-ten whites (62%) say they trust all or most of their neighbors, compared with 31% of blacks and 27% of Hispanics. While whites as a group are wealthier than blacks and Hispanics, there are still gaps in trust between whites and nonwhites of the same income brackets.

Looking at neighborhoods more broadly, our 2015 survey on U.S. parents found that 72% of white parents described their neighborhoods as excellent or very good places to raise children, compared with 41% of black parents and 42% of Hispanic parents. And research has shown that affluent blacks and Hispanics are more likely than affluent whites to live in poorer neighborhoods.

While the subject of neighborly trust is not as widely examined, there’s a large body of literature on social trust more generally. The General Social Survey, for example, has asked Americans since 1972 whether they think “most people can be trusted” or “you can’t be too careful in dealing with people.” A 2007 Pew Research Center report looked at the issue through a “social trust index,” which found the same kinds of demographic gaps in social trust back then as compared with the gaps in neighborly trust today. And in a separate 2008 global study, we found that people in nations with high levels of social trust also perceive lower levels of crime and corruption as very big problems.

Past studies suggest that ethno-racial differences in social trust may have ecological roots. A 2012 review by Sandra Susan Smith of the University of California, Berkeley finds two approaches in understanding these differences: The first looks at how trust levels are associated with the strength of community organizations and social structures locally; the second looks at why people in segregated neighborhoods are more likely to trust each other than are people in diverse neighborhoods.

Our survey also shows that younger Americans are less likely than older Americans to trust their neighbors, even when controlling for income differences and urban/rural differences. However, it’s hard to say whether this is due to younger people’s stage in their life cycle, or because today’s young adults are more distrusting than young adults of past eras.

Americans today are less likely to spend social evenings with their neighbors than in the past. In 1974, 61% of Americans said they would spend a social evening with someone in their neighborhood at least once a month, while 39% said they would do so less than once a month or not at all, according to the General Social Survey. Those shares have nearly flipped: In 2014, fewer than half (46%) said they spend social evenings with their neighbors at least monthly, compared with 54% who do not.

Note: Data for Americans’ trust in their neighbors were based on surveys from Pew Research Center’s American Trends Panel.