[R] 'R' and 'Yield to Maturity'

Craig P. Pyrame crappyr at gmail.com
Mon Feb 1 15:16:03 CET 2010


Be sure to check $estim.prec and use the parameter tol as needed.

Best regards,
Craig



Madhavi Bhave wrote:
> Dear Sir,
>  
> That was GREAT!!!. Thanks a lot for the solution. Once again it showed how powerful 'R' is otherwise I was breaking my head on Newton-Raphson method.
>  
> Thanks again Sir. That was really superb.
>  
> Madhavi
>
> --- On Mon, 1/2/10, S Ellison <S.Ellison at lgc.co.uk> wrote:
>
>
> From: S Ellison <S.Ellison at lgc.co.uk>
> Subject: Re: [R] 'R' and 'Yield to Maturity'
> To: "Craig P. Pyrame" <crappyr at gmail.com>, "Madhavi Bhave" <madhavi_bhave at yahoo.com>
> Cc: r-help at r-project.org
> Date: Monday, 1 February, 2010, 3:41 AM
>
>
> If you know the likely range, uniroot would do it.
>
> 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
>
>
>



More information about the R-help mailing list