https://www.nytimes.com/interactive/2014/upshot/buy-rent-cal...
What you will notice if you play around with it is that the decision is most sensitive to "What Does the Future Hold", in particular to the home price growth rate. If you expect that to even stabilize (let alone decline) then renting is almost always a better deal.
Now, that being said, I expected home prices to stabilize back in the early 2000's and didn't buy in SF, so I have been fooled before.