For most people, houses are machines for living in and not "investments". Given large up-front costs, you will almost always be in the hole for some amount of time after you purchase, but depending on what you buy and the alternative it can substantially lower your ongoing costs. Little of this has to do with year-to-year fluctuations in the housing market.
Of course, in SF, buying usually raises your ongoing costs. So...