WASHINGTON >> It's still possible in Boston for a mail carrier, an accountant and a Harvard-trained psychiatrist — basically, the crowd from "Cheers" — to live as neighbors.
That finding by the real estate brokerage Redfin makes the capital of Massachusetts a rarity at a time when neighborhoods in most U.S. cities are increasingly isolated from each other by income and home values.
Redfin analyzed home sales over the past 24 months in 20 major U.S. cities, breaking down the data by neighborhood. Many of the cities reflect home values that have outpaced wages over the past 15 years and contributed to a widening wealth gap among neighborhoods that mirrors a national trend.
San Francisco, for example, enjoys the benefits of tech fortunes, but its homes are largely unaffordable for the police officers, firefighters and teachers the city needs. And while housing in Baltimore seems affordable, low and unstable incomes there have depressed home ownership rates. Ribbons of highways have also ferried the middle class out of cities such as Detroit, leaving behind concentrations of poverty.
Redfin said its analysis is a first step in examining changes over time in neighborhoods and in economic mobility.
"Our argument is the shape of the American city is the shape of American life," said Glenn Kelman, CEO of Redfin. "When the only time you meet someone wealthy is when you're handing them a croissant, the likelihood that your kids are going to attend a good school and know how to pursue a career go down."
More than half of Boston contains a mix of high-end and affordable homes, compared with a national average of 13 percent. Boston's most economically mixed neighborhoods tend to be centered around its Roxbury district, a section that has been predominantly working class, black and Latino in a city with a long history of racial and ethnic divisions. Its growing economic diversity reflects the changing character of Roxbury, where many middle-income homebuyers are settling after being priced out of other sections of Boston.
The trend has unfolded in Roxbury neighborhoods such as Highland Park and Egleston Square. Real estate broker Christopher Buono said higher prices over the past five years in other areas of Boston have led more buyers into these neighborhoods. And the steady flow of students each year to the 35 colleges in Boston has made many homes attractive to investors seeking to rent them out.
Pockets of Roxbury were close to abandoned during the 1970s, said broker Deborah Bernat. But renovations and development have introduced condos and townhomes with such luxury features as gas fireplaces and balconies. The result has been a mixture of blue-collar residents with startup executives.
"Sustainable integration is the goal," Bernat said. "It's one of the things that I love about the neighborhood."
To assess affordability, Redfin compared sales prices to median incomes. Other cities with above-average levels of economic diversity include Denver, Seattle and Washington, D.C., which have benefited from an influx of educated workers and technology companies.
But high-tech can also widen the wealth gap. Almost all of San Francisco — the hub for the most prominent software and computer firms — consists of homes worth more than what a middle-income family there can afford. Other cities, such as Baltimore and Philadelphia, contain small clusters of wealthy neighborhoods along with large swaths of relatively low-priced homes, but many residents lack the stable income and savings to buy.
In some cases, the data suggest that better-off residents work in a city but live in the suburbs, so that only a small share of the city itself is economically diverse. A mix of high-end and affordable housing exists, for example, in less than 10 percent of San Antonio, Memphis, Jacksonville, Detroit, Indianapolis and Columbus, Ohio.
Home values began to climb faster than incomes in late 1999. Housing prices had long hewed closely to gains in average hourly earnings. But a gap developed between the two during the housing boom, narrowed slightly during the Great Recession and then widened again once the economy began to recover roughly six years ago.
The separation of neighborhoods by income has prevented children from progressing economically, according to research published last year by economists at Harvard University and the University of California, Berkeley. Boston ranked fourth in upward mobility. By contrast, Jacksonville, Detroit, Indianapolis and Columbus each ranked toward the bottom.
Many families face financial obstacles to send their children to schools that could enhance their economic prospects. A minority of the country can afford to buy homes in ZIP codes with high-quality schools, according to a report released Thursday by RealtyTrac, a real estate data company.
Homes are too expensive for average wage earners in 65 percent of ZIP codes with elementary schools where students performed above average on standardized tests. The median sales price for homes in ZIP codes with these schools was $411,573 — nearly double the median for homes in areas with lower-performing schools.