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.99997

$f.root
[1] -1.640646e+39

$iter
[1] 4

$estim.prec
[1] 6.103516e-05

.Machine$double.eps^0.25/2
[1] 6.103516e-05

uniroot thinks it has converged, at least in relative terms. Note that the estimated precision is related to the machine epsilon, used in the default value for "tol". try fiddling with the tol argument.

uniroot(f,c(0,100),tol=1/10^12)
$root
[1] 50

$f.root
[1] 1.337393e+31

$iter
[1] 4

$estim.prec
[1] 5.186962e-13

albyn


Quoting megh <megh700...@yahoo.com>:


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 root of a function, it must be near Zero.
Am I missing something?

--
View this message in context: http://www.nabble.com/uniroot%28%29-problem-tp21227702p21227702.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to