CHICAGO — A major study says the richest Americans live at least 10 years longer on average than the poorest, but the gap isn’t as wide in many communities, especially affluent, highly educated cities.

The research emphasizes that income plus where you live help determine life expectancy.

Stanford University economist Raj Chetty and colleagues analyzed more than 1 billion tax records between 1999 and 2014, along with government records on nearly 7 million deaths. They used the data to estimate life expectancy at age 40 by income and geographic area.

Their analysis was published online Monday in the Journal of the American Medical Association. It comes during an election season marked by heated debate about income equality and the endangered middle class.