There are a number of factors that go into your decision to buy or lease a car. Opportunity cost is one factor that might get overlooked, though. This calculator from MarketWatch considers the potential return you'd get by leasing and investing instead of buying. As MarketWatch explains, the argument against leasing often comes down to "you'll have nothing to show for your money", and that argument doesn't consider the opportunity cost. You could potentially invest the purchase price of the car and earn a return on it instead.
Of course, you can't predict the market return, and this implies you would actually invest the money instead of just spend it. So there are even more variables to think about. Still, the calculator is unique in that it at least gives you a rough idea what you might earn over time. You enter your details, including the expected return, and the tool tells you at what price point leasing would outweigh buying.
The calculator uses some general assumptions that might vary depending on your situation, but again, it gives you a rough idea that you can weigh against your decision to buy. Check it out at the link below.
Lease or Buy a Car? - Calculator [MarketWatch]