It is all quite confusing, because there are three separate dynamics. One is the performance of the underlying asset. Second is the after-tax cost of ownership versus renting the same asset. Third is the leverage.
You generally have addressed the three factors correctly, except for this: Leverage does not increase the inherent returns of an investment, but rather increases the risk of those returns. Your example was of the underlying asset increasing in value 4% year over year, but what about in the situations in which prices decrease? You easily lose your entire down payment, your credit is screwed, you maybe have to declare bankruptcy … plus, to add insult to injury, the IRS comes after you for the implied income of the debt forgiveness. Leverage is wonderful when it works in your favor, and downright awful when not.
Plus, the huge negative to housing is the transaction cost. You don’t pay 5-7% to sell a stock, no matter how leveraged you are.