Prospective home buyers may want to steer clear of the Bay State if they don’t want their purchase to break the bank.

Massachusetts ranked as the most expensive state to buy a home in, according to a report from personal-finance website SmartAsset. The analysis assessed 48 states and Washington, D.C., based on the following metrics (Delaware and Louisiana were not included due to insufficient data):

Effective property tax rate, based on U.S. Census Bureau data

Median listing price and price per square foot, according to Zillow ZG, +3.85%

Median value for homes in the bottom third of the market

Average closing costs, according to SmartAsset’s own closing cost calculator

All the states were ranked for each of these metrics, and then researchers calculated their average ranking. This then determined the index value they were assigned on a scale from 0 to 100, with 100 being the cheapest. Massachusetts’ index came in at zero, while West Virginia was the most affordable state with a value of 100.

Don’t miss:Mortgage rates increase slightly, pumping the brakes on the refinance boom

Home prices were actually lower in Massachusetts than other notoriously expensive states such as California and Hawaii. The median listing price in Massachusetts was $479,900, versus $550,000 for California and a whopping $632,500 for Hawaii.

However, Massachusetts had a relatively higher effective property tax rate (1.18%) than both of those states. Even then, the Bay State had far from the highest tax rate in the country — that honor went to New Jersey, whose property tax rate of 2.43% contributed to it ranking as the second most expensive state nationwide.

West Virginia, meanwhile, is a haven for house hunters looking for a bargain. The state not only had lowest median listing price in the country at $169,900, but also one of the lowest property tax rates at just 0.57%.

Overall, the South and Midwest were the cheapest places to be a homeowner, with states from these regions, such as Arkansas and Indiana, ranking among the most affordable.