Based on your financial expertise, provide your response or viewpoint on the given financial question or topic. The response format is open.

Formula that predicts whether one is better off investing or paying down debt
I ended up writing a simulation in R. Here is my code: It produces a plot like this:  This code assumes you have a lump sum and either wish to pay down a loan or invest it all immediately. Feedback welcome.