I think there could be a quantifiable scenario where if one had <X yrs left, given a generally accepted asset allocation, she'd be better served to either pay it off or refinance to a longer term to increase the probability of success. X is a number I don't know, but it must exist. I'll do my best try to run some calcs & post them. If it helps out one person it'll have been a worthwhile exercise. Especially if that person is me ;).
Now that's an interesting problem. Seems you'll have to specify "by how much?" or "to what value?" regarding "increase the probability of success" somewhere in the analysis. Looking forward to what you get.
I don't understand the question being examined. Once we've assumed that the CAGR is higher than the mortgage rate over the long term, then the answer will always be that it's better to refinance to a longer term if the same (or lower) mortgage rate is available at the time of the refinancing (assuming that any transaction costs associated with the refinancing are low enough).
Is the question really just looking for a breakeven point in the "remaining years to maturity" variable as far as the expected optimality of payoff vs. investing, assuming that refinancing/term-extension is not an option (because, for example, then-prevailing mortgage rates are prohibitively high)?
I look forward to seeing the analysis too. BBub, are you going to look at actual historical data, or just run calculations using a given set of assumptions for all the variables?
I just ran a quick cFIREsim run (using the same methodology described
here and
here) to check the historical odds of coming out ahead by keeping your mortgage outstanding with only 5 years remaining until maturity on a 4% mortgage using cFIREsim's default settings for asset allocation and investment expenses, and it reported an answer of 58.57% (but that may be understating the actual "success rate" of retaining the mortgage, because, as noted in the second linked post above, in a control test using assumed fixed investment returns, cFIREsim understates the success rate of retaining a mortgage (most likely due to its built-in assumptions about the timing of portfolio withdrawals not lining up with the timing of a mortgage's monthly amortization schedule)).
EDIT: For every $100k of mortgage that remains outstanding with a 5-year remaining life to maturity and a 4% mortgage rate, the historical median amount by which the "mortgage-retainor" came out ahead was $1,597.60, with a standard deviation of $4,955.01. The historical arithmetic average amount by which the mortgage-retainor came out ahead was $2,254.69. In the absolute best-case scenario, he/she came out ahead by $18,749.39. In the absolute worst-case scenario, he/she came out behind by $9,510.38