The example I gave you was intended to be of an up front investment of the total principal.
This was after I explained that one of the major differences between investing and buying is that one is typically
done on margin, which distorts the comparison.
This was just to make things more simple and apples to apples though. Obviously, most people don't have 300-500k or whatever to drop on a house in cash. The thing is, as long as total return is higher than the interest rate, you're effectively increasing the amount you invest by buying a house, because it is done
on margin.
To put it another way, if your mortgage rate is 4% (with tax benefits and current rates it will usually effectively be lower), and you're earning 6%, the opportunity cost on the down payment ought to be compared against the net gain (2% let's say, 6-4) on the
principal net of loan, which will typically start off being at least 4x larger -- in addition to the gross gain(6%) on the share with the interest paid off(say 20% down initially and increasing over time as it gets paid off). Your opportunity cost here is literally nothing, because most people don't weigh borrowing to buy a home against borrowing to invest more in the stock market.
Yet another way of saying this is that one of the major advantages of having a home is that it gives you easy access to credit to let you invest in an asset which will reliably pay you more than the associated debt (again, the tax benefits lowering the cost of debt helps).
The 5% I cited was intended to be net of property taxes. Property tax payments are different from the mortgage interest because they are paid in perpetuity. They are of course net of tax as well, which is nice and softens the blow, but ideally should be netted against the rental value when determining the flow payment.