For renters and homeowners alike, finding an affordable place to live in the San Francisco Bay Area is like discovering the needle in an ever-increasing haystack. And there’s no sign of prices falling anytime soon as the strong job market in San Francisco and Silicon Valley lure more people to the area.

With a 33% increase in home prices across the Bay Area from 2011 to 2013, in many cases, it might make more sense now to rent than to buy. In 2012, buying a home in the Bay Area was 24% cheaper than renting, but by May 2014, that difference had flipped, and it’s 6% more expensive now to buy than rent, according to the New York Times.

And with companies continuing to add employees, every year more people are looking for housing in the area. In 2013 alone, San Francisco added 10,600 people, and San Jose saw 17,000 new residents. If you are new to the region or are looking for a new place to live, you’ve probably wondered: Should I rent or buy, and where?

After analyzing 65 Bay Area cities, NerdWallet discovered it’s not the East Bay, but places in Silicon Valley where renters will find more significant differences in costs between renting and buying. In our top three cities — Palo Alto, Cupertino and Los Gatos, which are all in Santa Clara County — the median home price is typically 28 times the annual rent for a home of the same size, based on the price-to-rent ratios at the real estate website Zillow.

Looking across the Bay Area, 13 of our top 20 cities for renters are in the two counties south of San Francisco — San Mateo and Santa Clara — where price-to-rent ratios are much higher overall than in the East Bay’s Alameda and Solano counties.

To determine what goes into a market that favors renting, we considered three main questions:

Is it better to rent than to buy? From Zillow, we gathered price-to-rent ratios from July through September 2014. A higher price-to-rent ratio was weighted positively. A price-to-rent ratio is calculated by dividing the median home price by a year’s worth of rental costs. In other words, a 14 means the median home price is typically 14 times the annual rent for a home of the same size. Of course, buying still might be a worthwhile investment over time depending on your mortgage and if you plan to stay awhile.

For the Bay Area, we made 15 our benchmark based on a calculation by the New York Times, so 15 or over means that it’s better to rent than to buy over the long run. But if you are set on buying, we found nine places — Vallejo, San Pablo, Pittsburg, Suisun City, Richmond, Antioch, East Palo Alto, Oakley and Fairfield — where it’s better to become a homeowner.

Are rental units available? Using the most recent U.S. Census Bureau data (5-year 2013 American Community Survey estimates), we equally weighted the percentage of renter-occupied housing and the median rental vacancy rate. High percentages of renters and vacancy rates were weighted positively. A city favorable for renting must have available units, especially since only 12 of the 65 Bay Area cities had a vacancy rate at or above the state’s rate of 4.9%.

Is rent affordable based on an area’s median household income? From Zillow’s website, we took a year’s worth of median monthly rents averaged from July to September 2014 and divided that by the median household income, which was compiled from census data. This gave us each area’s rent as a percentage of income. A lower percentage scored positively.

In calculating affordability by using median figures, we found that only about a third of cities have rents less than 30% of income, which NerdWallet recommends as a healthy percentage to spend on housing costs.

Want to know about future NerdWallet studies first? Click here to have updates sent to your inbox.

Here are some other trends we discovered in our analysis:

Price-to-rent ratios make a difference. The places with the highest price-to-rent ratios shot up to the top even though we averaged the three factors equally.

Cities with technology companies ranked well. Each one of the top five cities is home to facilities or headquarters of major technology companies. Perhaps unsurprisingly, median incomes above $100,000 reflect the competitive job markets in those areas. However, certain cities, such as Mountain View, scored lower because of its low supply of rental units.

NerdWallet crunched the data for 65 places with over 20,000 residents in the San Francisco Bay Area’s cities and towns. To see the full data set, click here.

Best Cities to Rent, Not Buy, in the San Francisco Bay Area

1. Palo Alto
Home to Stanford University students and technology professionals, Palo Alto’s housing stock skews toward renters. With 44.6% of housing counted as rentals and the second-highest price-to-rent ratio in the Bay Area at 31.77, it tends to be better to rent than to buy a home here. According to Zillow data, the median home price by fall 2013 had topped $2 million.

2. Cupertino
Cupertino, one of the most affluent cities in Silicon Valley, is the headquarters of Apple, which helps explain the median household income of $129,976. But even with those higher incomes, the price-to-rent ratio of 29.61 indicates that for most people it’s better to rent than to buy a home here. The rental vacancy rate of 4.9% is the highest of the top 20 cities.

3. Los Gatos
In the town of Los Gatos, southwest of San Jose, renters spend about 28.7% of their median household income of $122,476 on rent costs. But it can be more difficult to find a place — vacancy rates and the percentage of housing for renters are lower here than in other cities in our top 10. With one of the highest price-to-rent ratios from our list, renting is 28 times cheaper than buying in Los Gatos. Netflix and Digital Media Academy have based their headquarters in the city.

4. Sunnyvale
In this Silicon Valley city near San Jose, renters pay the lowest median rent of our top 10 at $2,723, and 53% — the highest percentage on our list — of housing is renter occupied, according to census data. Sunnyvale is home to companies such as Yahoo, Lockheed Martin and more.

5. Burlingame
Renters in Burlingame, which is near the San Francisco International Airport, will find a lower median rent here than in other cities in the top 10. Renting is 27.18 times cheaper than buying, based on its price-to-rent ratio. With stops for the Caltrain commuter line, Burlingame is accessible for residents who work in the south bay and valley and also those who commute north to San Francisco.

6. Menlo Park
Home to Facebook and the Stanford Research Institute, Menlo Park has an expensive housing market. Its price-to-rent ratio is 27.18, but census figures show there’s a strong supply of housing for renting, with 43.8% of units renter occupied. Affordability is not one of its virtues, even for those at the median income here, since renters spend roughly 41.3% of their income of $112,262 on housing costs.

7. Campbell
This small San Jose neighbor walks a different path than the other cities in Silicon Valley: It isn’t a base for computer giants, but Campbell is big for people who don’t own a home — 48.2% of housing is occupied by renters.

8. Santa Clara
Santa Clara, San Jose’s neighbor, boasts a large renter population, with 54.9% of housing occupied by renters, in part because of the student population at Santa Clara University and people who work at Applied Materials, Intel and other companies in the city. The median rent of $2,740 is comparable to other cities in the top 10, but its price-to-rent ratio of 21.13 is lower.

9. Fremont
As the closest East Bay city to Silicon Valley, Fremont still has a high median rent of $2,319. Renters spend 27.41% of the median household income of $101,535 on housing costs. Its price-to-rent ratio and percentage of rental housing are lower than in other cities in the top 10, though, making it friendlier for homeowners.

10. Dublin
This city in Alameda County has grown by over 30,000 people in the past few decades, but only 35.6% of housing is renter occupied. Compared to the top nine cities, future homeowners will find Dublin is a better choice with its lower price-to-rent ratio of 20.15. But there’s good news, too, if you plan to rent — the city’s vacancy rate of 5.9% is relatively high for the Bay Area.

Source: http://www.nerdwallet.com/blog/cities/economics/best-cities-rent-not-buy-sf-bay-area