Overall, Massachusetts ranked ahead of the nation.
Seventeen percent of the 433 Massachusetts nursing homes reviewed were given five stars, ahead of the national average of 12 percent. Just 14 percent were rated with a single star, far fewer than the national average of 22 percent.
But a deeper look at the Massachusetts statistics revealed that nursing homes in more affluent counties often ranked higher than nursing homes in poorer counties.
In Middlesex County, one of the wealthiest counties in Massachusetts based on median household income, nearly 60 percent of nursing homes were rated with either four or five stars - the second highest of any county in the state, based on the AP review.
By contrast, in Hampden County, the poorest county in the state, nearly six out of ten nursing homes were ranked with just one or two stars. The county also ranked last in the percentage of five-star nursing homes.
Other counties saw a similar pattern.
Plymouth County, the third wealthiest in the state, also ranked third in the list of counties with the highest percentage of four and five-star nursing homes.
Berkshire County, the second poorest county by income, had the highest percentage of nursing homes with the worst rating of just one star.
And in Worcester County, with a median income slightly below the statewide average, one out of four nursing homes were given single star ratings, while about one in ten were given the top rating.
There were a few exceptions.
In Norfolk County, the state's wealthiest based on income, just a third of the facilities were rated with four or five stars, leaving it in the middle of the pack, although it did have the lowest percentage of one-star nursing homes.
And Suffolk County, the third poorest county by income, had the highest percentage of five-star nursing homes and one of the lowest percentage of one-star homes. Suffolk County includes Boston, with its high concentration of teaching hospitals and healthcare facilities.
The AP review looked only at counties with more than 10 nursing homes, exempting Dukes, Franklin, Hampshire, and Nantucket counties.