Displaying 1 result from an estimated 1 matches for "elisson".
Did you mean:
eliason
2010 Feb 02
2
Yield to Maturity using R
...priced at 101. The yield to maturity can be calculated after solving the equation -
1010 = [100 / (1+ytm)] + [100 / (1+ytm)^2] + [ 1100 / (1 + ytm)^3]
This can be solved by trial and error method s.t. ytm = 9.601%. I wanted to find out how to solve this equation in R.
## SOLUTION
Mr. Elisson had given me following wonderful solution
f.ytm<-function(ytm) 100 / (1+ytm) +100 / ((1+ytm)^2) + 1100 / ((1 +
ytm)^3) -1010
uniroot(f.ytm, interval=c(0,25))
#$root has the answer
And I got the answer as 9.601.
## _____________________________________________________________
I was...