The two main forces behind the cost of debt are the risk of default and the time to maturity. Risk and time to maturity are not fully independent, as the risk of debt is decreasing when the debt is nearing maturity. The higher the risk, the higher the cost of debt. The longer the maturity, the higher the cost of debt is as the risk of default increases. When debt is guaranteed by a credible government, it can be regarded as risk-free. In this case, the cost of debt is a function of the time to maturity only and becomes dominated by the term structure of inflation. If inflation is expected to be lower in the future than today, then the cost of fixed-rate long-term debt can be lower than the cost of short-term debt.
The cost of debt is determined in the market by the laws of supply and demand. When new debt is issued by companies or governments, it has to attract sufficient interest so must be in line with current market coupon rates. Once debt has been issued, its value and yield will vary over time to adjust to the coupon rates currently offered for new debt of the same maturity and risk. If the coupon rate for new debt of the same structure (risk, maturity) is lower, then the value of the debt previously issued will rise so that the yield that it serves is the same as the coupon rate on the newly issued debt.
The cost of debt is defined as the current yield on equivalent risk class debt with the same maturity period. So to calculate the cost of debt, we need a theory of debt risk. When the risk is small, the debt can be approximately seen as risk-free. In this case, the value and cost of debt are linked by a deterministic relationship so that if one is known, the other can be derived. For instance, if the value of debt can be directly observed on the stock market, then its cost can be inferred.
Debt can be callable. This means that the borrower has a call option to reimburse the face value of the debt before redemption. Callable debt has to offer higher coupon to attract debt holders, so its cost is higher. The advantage for companies is to be able to refinance at a lower cost if interest rates have decreased in the meantime.
With convertible debt, the borrower can convert debt into equity at his discretion if certain conditions are met, typically if the share price has fallen below a certain level. More commonly, convertible bonds give lenders the right to convert the bond into shares over a certain time period at an exchange ratio known in advance. This can be attractive to lenders if the share price increases strongly. The advantage for companies is to finance risky debt at a lower coupon rate and compensate with an opportunity to participate in the increase in the value of the equity should the company succeed and its share price increase.
There are many other forms of debt than those briefly addressed above. Financial institution do not lack creativity to meet the ever-evolving expectations of their customers. When debt is issued, its terms are set in a contract whose objectives are to protect the lenders against the borrower. Whereas contracts for public debt are fairly standardised, private debt contracts can contain a lot more unusual features, many of them are options either held by the borrower or the lender. To value callable and convertible debt for instance, it is necessary to know how to value options on the underlying equity.