Well, thinking this through in laymen terms...you'll want:

- Home Value
- Mortgage Amount Remaining
- Years Left on Mortgage
- Cost to Sell Home
- Home Appreciation Rate
- Gross Rents (annual)
- Expenses (annual) (Not including principal + interest on loan)
- Investment RoR
- Inflation Rate

Where the output would be a graph over time (x) with the following formula:

Sell Home Now = (#1-#2-#4) * (1 + #8) ^ x

Rent At Loss = Sum of total opportunity lost on cashflow for through year x + cash out (potentially negative) at sale at year x

WHERE

Cash out at sale = Appreciated home value - remaining mortgage amount - inflated cost to sell

Sum of total opportunity lost on cashflow = Summation(x=1, MAX(x)) sum of total opportunity lost on cashflow at year x

Sum of total opportunity lost on cashflow at year x = Sum of (negative) cashflow at year x * (1 + #8) ^ (MAX(x) - x)

Sum of (negative) cashflow at year x = Inflated gross rent at year x - inflated gross expenses at year x - mortgage payment

Then you can just look at the graph and see how long you'd have to keep the house to make it worth it (if ever)

Leaving some of these as generic as I just don't want to write it all out right now. This seem correct/incorrect?