Estimating the yield of a bond

Bond Valuation and Analysis in R

Clifford Ang

Senior Vice President, Compass Lexecon

Finding the yield by trial-and-error

  • For traded bonds, we can imply the yield
  • If you know the price and the bond's cash flows, you can make "guesses" as to the yield
  • The "correct" yield equates the price of the bond with the PV of the bond's cash flows
Bond Valuation and Analysis in R

Iterating through different guesses

  • Consider bond with $100 par value, 5% coupon rate, 10 years to maturity, and a price of $92.64
  • 1st Guess: 5% → Price is $100 (too high)
  • 2nd Guess: 7% → Price is $85.95 (too low)
  • 3rd Guess: 6% → Price is $92.64 (correct)
Bond Valuation and Analysis in R

Automating the process

  • Trial-and-error is inefficient
  • Fortunately, we can use the uniroot() function in R to help us automate the process
Bond Valuation and Analysis in R

Create function using uniroot()

ytm <- function(cf) {
    uniroot(bval, c(0, 1), cf = cf)$root
}
  • Create the ytm() function using uniroot()
  • Function takes a modified cash flow vector (cf) and uses a modified bond valuation function (bval)
  • c(0,1) limits the interval for the search to a yield between 0% and 100%
Bond Valuation and Analysis in R

Modified cash flow vector

cf <- c(-92.64, 5, 5, 5, 5, 5, 5, 5, 5, 5, 105)
  • First element is bond's price entered as a negative number
  • Second element onwards are the bond's cash flows - coupons plus par value
  • Same bond: Price is -$\$92.64$, par value is $\$100$, 5% coupon rate, and 10 years to maturity
Bond Valuation and Analysis in R

Modified bond valuation function

bval <- function(i, cf, t = seq(along = cf))  sum(cf / (1 + i)^t)
  • Need to create bond valuation function bval() that uses the modified cash flow vector (cf)
  • Same logic as our bondprc() function
  • Create time indicator (t)
  • Discount cash flow using interest rate (i)
Bond Valuation and Analysis in R

Let's practice!

Bond Valuation and Analysis in R

Preparing Video For Download...