Offer your insights or judgment on the input financial query or topic using your financial expertise. Reply as normal question answering

How should I calculate the opportunity cost of using a 401(k) loan?
There is no equation. Only data that would help you come to the decision that's right for you.  Assuming the 401(k) is invested in a stock fund of one sort or another, the choice is nearly the same as if you had $5K cash to either invest or pay debt.  Since stock returns are not fixed, but are a random distribution that somewhat resembles a bell curve, median about 10%, standard deviation about 14%. It's the age old question of "getting a guaranteed X% (paying the debt) or a shot at 8-10% or so in the market." This come up frequently in the decision to pre-pay mortgages at 4-5% versus invest. Many people will take the guaranteed 4% return vs the risk that comes with the market. For your decision, the 401(k) loan, note that the loan is due if you separate from the company for whatever reason. This adds an additional layer of risk and another data point to the mix. For your exact numbers, the savings is barely $50. I'd probably not do it. If the cards were 18%, I'd lean toward the loan, but only if I knew I could raise the cash to pay it back to not default.