How much house you can afford depends on where you live

Your ability to own a home is affected by where you live. Even people with modest incomes can afford homes in Decatur, Illinois, the metropolitan area with the nation's most affordable houses. At the other end of the affordability spectrum is the San Jose, California, metro area, where high incomes are outmatched by stratospheric home prices.

A home is most affordable when it doesn't cost much more than a year's pay. Decatur is an affordable market because the median house costs about one and a half times the median annual income. ("Median" is the midpoint, where half of the values or incomes are lower and half higher.) In comparison, there's San Jose, where a typical household earns a six-figure income but a median single-family house costs about 12 times what a typical household earns.

Every quarter, NerdWallet calculates home affordability for 172 metropolitan areas by comparing the median annual household income and the monthly principal-and-interest payment for a median-priced single-family home. After accounting for a 20 percent down payment, the house payments were calculated at an interest rate of 4.45 percent, the average rate for a 30-year fixed-rate mortgage in the first quarter; payments don't include insurance, property taxes or homeowner association dues.

The comparisons revealed the five most- and least-affordable markets for buying a home in January through March, or the first quarter of 2018. The rankings were compiled using data from the National Association of Realtors, the Census Bureau and NerdWallet surveys.

MOST-AFFORDABLE METRO AREAS

1. DECATUR, ILLINOIS

Median home price: $73,000

Median household income: $46,198

Principal and interest payment: $294 (equals 7.6 percent of median monthly income)

In March, single-family homes for sale in Decatur had been on the market for a median of 119.5 days, according to Realtor.com. The national median for all home sales was 63 days.

2. CUMBERLAND, MARYLAND-WEST VIRGINIA

Median home price: $86,200

Median household income: $45,808

Principal and interest payment: $347 (9.1 percent of monthly income)

Listed homes in Cumberland had been on the market a median of 136.75 days in March.

3. ELMIRA, NEW YORK

Median home price: $100,800

Median household income: $51,269

Principal and interest payment: $406 (9.5 percent of monthly income)

Homes in Elmira had been on the market for a median of 97.5 days in March, just over a month longer than the national median.

4. BINGHAMTON, NEW YORK

Median home price: $103,000

Median household income: $51,360

Principal and interest payment: $415 (9.7 percent of monthly income)

Homes for sale in Binghamton had been listed a median of 108.5 days in March.

5. PEORIA, ILLINOIS

Median home price: $114,800

Median household income: $57,090

Principal and interest payment: $463 (9.7 percent of monthly income)

Peoria was the quickest-selling market among the five most-affordable, with homes listed a median of 77.25 days in March.

LEAST-AFFORDABLE METRO AREAS

1. SAN JOSE-SUNNYVALE-SANTA CLARA, CALIFORNIA

Median home price: $1.37 million

Median household income: $110,040

Principal and interest payment: $5,533 (60.3 percent of median monthly income)

Buyers have to act fast in the San Jose area, the center of Silicon Valley: For-sale homes spent a median 17 days on the market in March, according to Realtor.com.

2. HONOLULU, HAWAII

Median home price: $775,500

Median household income: $80,513

Principal and interest payment: $3,125 (46.6 percent of monthly income)

Honolulu, a popular market for international buyers, had a median days-on-market of 52 days in March, according to Realtor.com.

3. SAN FRANCISCO-OAKLAND-HAYWARD, CALIFORNIA

Median home price: $917,000

Median household income: $96,677

Principal and interest payment: $3,695 (45.9 percent of monthly income)

Just to the north of Silicon Valley, homes here sell almost as fast. In the San Francisco, Oakland and Hayward area, homes spent a median of just 22 days on the market in March, according to Realtor.com.

4. SAN DIEGO-CARLSBAD, CALIFORNIA

Median home price: $610,000

Median household income: $70,824

Principal and interest payment: $2,458 (41.6 percent of monthly income)

California has four of the five least-affordable metro areas. San Diego homes were listed a median 32.5 days in March, according to Realtor.com.

5. LOS ANGELES-LONG BEACH, CALIFORNIA

Median home price: $545,500

Median household income: $65,950

Principal and interest payment: $2,198 (40 percent of monthly income)

Homes for sale in the Los Angeles area had been on the market a median of 33.5 days in March, according to Realtor.com.

Data sources:

National Association of Realtors' median metro home prices for the first quarter of 2018

The Census Bureau's median household income from the 2016 American Community Survey 1-year series (the latest available data)

NerdWallet's daily mortgage rate survey

Realtor.com's market trends data from March

This article was provided to The Associated Press by the personal finance website NerdWallet. Holden Lewis is a writer at NerdWallet. Email: hlewis@nerdwallet.com. Twitter: @HoldenL.

RELATED LINKS:

NerdWallet: Tips for first-time home buyershttps://nerd.me/tips-first-time-home-buyers

NAR metropolitan median prices and affordabilityhttps://www.nar.realtor/research-and-statistics/housing-statistics/metropolitan-median-area-prices-and-affordability

Realtor.com market trends datahttps://www.realtor.com/research/data