[R] uniroot() problem

2008-12-30 Thread megh
I have a strange problem with uniroot() function. Here is the result : > uniroot(th, c(-20, 20)) $root [1] 4.216521e-05 $f.root [1] 16.66423 $iter [1] 27 $estim.prec [1] 6.103516e-05 Pls forgive for not reproducing whole code, here my question is how "f.root" can be 16.66423? As it is finding

[R] uniroot problem

2018-12-19 Thread Troels Ring
Dear friends and helpers - in the script below, uniroot is called with a function CHB that calls a function, Charge. On its own, CHB apparently does what is expected, but from within uniroot, problems appear. An error is thrown Error in f(lower, ...) : could not find function "f" So CHB is not s

Re: [R] uniroot() problem

2008-12-30 Thread Albyn Jones
One can't tell for sure without seeing the function, but I'd guess that you have a numerical issue. Here is an example to reflect upon: f=function(x) (exp(x)-exp(50))*(exp(x)+exp(50)) uniroot(f,c(0,100)) $root [1] 49.7 $f.root [1] -1.640646e+39 $iter [1] 4 $estim.prec [1] 6.103516e-

Re: [R] uniroot() problem

2009-02-09 Thread megh
Thanks for this reply. Here I was trying to calculate implied volatility using BS formula. This is my code : oo = 384.40 # traded option price uu = 1563.25 # underlying price tt = 0.656 # time to maturity in year ii = 2.309/100 # interest rate, annualized th.price = function(x)

Re: [R] uniroot() problem

2009-02-09 Thread megh
Sorry, in my previous post I forgot to include strike price, which is K = 1160 megh wrote: > > Thanks for this reply. Here I was trying to calculate implied volatility > using BS formula. This is my code : > > oo = 384.40 # traded option price > uu = 1563.25 # underlying price > tt =

Re: [R] uniroot() problem

2009-02-09 Thread Ravi Varadhan
Varadhan.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of megh Sent: Monday, February 09, 2009 4:27 AM To: r-help@r-project.org Subject: Re: [R] uniroot() problem Thanks for this reply. Here I was trying to calculate implied volatility usi

Re: [R] uniroot problem

2018-12-19 Thread Troels Ring
Thanks a lot - f was renamed FF and things are OK BW Troels -Oprindelig meddelelse- Fra: Berwin A Turlach Sendt: 19. december 2018 10:27 Til: Troels Ring Emne: Re: [R] uniroot problem G'day Troels, On Wed, 19 Dec 2018 10:03:09 +0100 "Troels Ring" wrote: > Dear f