Did you ever wonder if you should buy an appartment or house instead of renting it?
If so, you are not the first and for sure, you will not be the last one to ask this question.
In the following article I will show you how I tried to derive an answer for myself. But disclaimers first :)
 I am not a real estate expert
 every situation is different and needs to be judged individually
 so please only take this as a rough guideance to real estate investment
So, you have been renting your appartment for several years and you want to decide what to do with the money you were able to put aside in all those years. From a broad perspective you have the following possibilities to invest your savings:
 Invest into the stock market
 Invest it into bonds/fixed income
 Buy your own appartment (and stop paying rent)
To understand which of these investments makes most economical sense, we need to compare cost end return of each option. The following table gives an overview for the three investment options. Average return of bonds and stocks (reinvesting coupon/dividend) over 70 years derived from data provided by Campbell R. Harvey of Duke University. Those values are not adjusted for taxes.
Investment  Bonds  Stocks  Real Estate 

Return before tax  ~2% (adjusted for inflation)  ~7% (adjusted for inflation)  rent you would pay if you would not own the house 
Costs  rent you pay  rent you pay  maintenance (~1%) interest for mortgage 
To compare the Real Estate investment with bonds and stocks, let us try to estimate the return on investment before tax for different market scenarios. Basis for this estimate is the swiss real estate market with a high in 1990 after which it dropped till about the year 2000 and steadily rises since then. Taking the average rent for 6 rooms as published by the HEV, and gross yield and interest rates taken from several publications of the Zürcher Kantonalbank, allows to calculate a rough price for the 6 rooms. The price you would pay equals the average rent devided by the gross yield.
time period  Interest rate (10y mortgage) 
gross yield  Rent  Price rent/gross yield 

~1990  7%  3.5%  21500  614000 
~2000  5%  6%  25750  430000 
~2014  2%  4%  30000  750000 
Assuming the bank requires 20% down payment to give you a mortgage, the return on your investment (ROI) can be calculated as follows. The income is the rent listed above while the costs would contain 1% of the buying price to pay for maintenance and the interest you pay for the mortgage. Substracting this from the income and deviding by the investment sum gives you the return. As the next table shows, low gross yield and high interest rates result in a negative return explaining the huge downturn (20% to 35%) of the market after 1990. On the other hand, the return on investment is comparable to stocks and bonds for the other two scenarios. Another intersting fact: Paying to principal does not make sense for the 2014 scenario as the return on investment is 5% higher than the interest you pay for the mortgage. Of course this only holds true as long as the interest rates remain lower than the ROI.
time period  Investment  maintenance (~1%)  interest  total cost  ROI  return on price 

~1990  123000  6000  34000  40000  15.5%  3.1% 
~2000  86000  4300  17200  21500  5%  1% 
~2014  150000  7500  12000  19500  7%  1.4% 
As a last comparison let us see how buying a house in 2000/2014 compares to stocks / bonds after inflation. The total amount of investment will be 150'000 CHF. For simplicity we asume an annuity mortgage with a fixed interest until the mortgage is payed off and assume the house can be sold for 600'000 CHF at the end of the periode. Incidentially the duration of the 2000 and 2014 mortgage is 33 years which will be our investment horizon for stocks and bonds. The 64'000 CHF of free capital in 2000 will be invested in stocks/bonds as well.
To better compare the 2000 and 2014 scenario, we multiply all values (except the saving available for investing) from 2000 by (30000/24750). This ensures that rental costs are the same for both scenarios. This increases the down payment to 100'000 CHF leaving 50'000 CHF for the stock market. Investing in stocks for 33 years results in a return of 1% to 9% after tax (to be shown in a separate article). For bonds I assume 1% per year. Maintenance will be assumed 5'000 CHF / year.
Scenario  Investment  return  cost of living  Interest +  Net return  

house  stocks  bonds  house  stocks  bonds  Maintenance  
stocks  0  150'000  0  Min: 208'000 Max: 2'580'000 
0  990'000  0  Min:782'000 Max:1'590'000 

bonds  0  0  150'000  0  208'000  990'000  0  782'000  
~2000 stocks 
100'000 
50'000 
0  600'000  Min: 69'000 Max: 860'000 
0  0  590'000  Min: 79'000 Max: 890'000 
2000 bonds 
100'000  0  50'000  600'000  0 
69'000 
0  590'000  79'000 
~2014  150'000  0  0  600'000  0  0  0  390'000  210'000 
Summary
Of course the numbers presented above can be adjusted in either direction and the following points are not taken into consideration
 You won't find an anuity mortgage running for 33 years. But then 20 years are not that uncommen anymore.
 Especially when interest rates are high, a libor mortgage might be more advisable than an anuity mortgage
 The following specialties of the swiss market were ignored
 The "Eigenmietwert": Living in your own house, you need to pay tax on a virtual income comparable to the rent you would receive if renting it out.
 Rent adjustments are coupled to the change of average market interest rates
In any case  on average , I think the following conclusions can be draw from the numbers above
 Buying for the right price, you will be able to generate a positive return when buying a house.
 You might be better off by investing into stocks, but then the contrary might be the case as well
 Investing in bonds, from an inflation point of view, probably is not an option