Get startedGet started for free

Estimating the yield of a bond

1. Estimating the yield of a bond

In the prior video, we showed how to find the yield of a bond by using the yield on comparable bonds.

2. Finding the yield by trial-and-error

But, for a traded bond, we can calculate the yield implied by the bond's price. This is the yield that market participants put on the bond. To find the yield, you use trial-and-error. You plug in different yields in the bond valuation function until the value you calculate equals the bond's price.

3. Iterating through different guesses

How does this work? Suppose you have a bond with $100 par value, 5% coupon rate, 10 years to maturity, and a price of $92.64 and you want to know the yield. You make a first guess, say a yield of 5%. This gets you a value of $100 but the bond price is lower. Recall that there is an inverse relationship between the bond's price and its yield. So you would need a higher yield estimate. Now you can try a yield of 7%. This gets you $85.95. This price is too low, so we have to lower the yield. Now, let's try 6%. This results in a value of $92.64, which matches our price. So the yield of this bond is 6%.

4. Automating the process

For one bond, trial-and-error may not appear to be too bad. But, with many bonds, this is extremely cumbersome. Fortunately, R has the uniroot() function. We won't go into the details of the uniroot() function, but for our purposes it is sufficient to know that using uniroot() allows us automate the trial-and-error process.

5. Create function using uniroot()

We now create the ytm() function that applies uniroot(). This function requires us to create a modified cash flow vector cf and modified bond valuation function bval. The uniroot() function then uses bval() and cf to determine the yield. The c(0,1) limits the interval for the search to a yield between 0 and 100%, which essentially covers more than the reasonable range of yields.

6. Modified cash flow vector

The cash flow vector used in the ytm() function is modified because we have to include the bond price as the first element of the vector. The price must be entered as a negative number because it is a cash outflow. Then, the coupon and principal payments are entered as positive numbers because they are cash inflows.

7. Modified bond valuation function

Finally, the bond valuation function "bval()" used in the ytm() function is modified because it has to use the modified cash flow vector. The idea of this modified bond valuation function is similar to the bond valuation function you learned in Chapter One. You first create a time indicator and then discount the cash flows using some interest rate "i".

8. Let's practice!

Now, let's practice finding the yield, first with some trial-and-error and then using the ytm() function.