[R] a bug and a question
gwhite at bodnext.bio.dfo.ca
Wed Jan 13 13:23:32 CET 1999
Two things to consider: a) different settings for the f.p. unit, and
b) different optimizations by the compiler
You can check .Machine -- I haven't used R on Win32, but from other
programs I know that the rounding mode ($double.rounding) is not always
predictable. I remember some discussion over whether .Machine should be
computed once at compile time or as part of the startup code each time R
is run. I now have an example (GNU Fortran in a telnet session under OS/2
Warp 4) in which the IEEE rounding mode changes after the first Fortran
write statement, so even if the rounding mode _is_ determined at startup,
it can be altered while a program is running.
Supporting scientific software on Win32 (and OS/2, which shares some
fundamental problems) is not easy!
You might want to check the value of $double.rounding in your code --
ideally it should be 5 (gradual underflow using denormals). This can
make a big difference to programs using finite differences to approximate
derivatives or in cases of cancellation (summing alternating series).
If you use f.d. for derivatives, it can help to condition the value
of "h", e.g.,:
for f'(x) ~ (f(x)-f(x+h))/h
you want to use:
xph = x + h
h2 = xph - h // conditioned value for h, but watch for optimizations!
f'(x) ~ (f(x)-f(xph))/h2
since (x+h) may not be representable in the machine. The reason I
suspect the IEEE rounding mode is that a) I know it is unpredictable, and
b) underflow in computing (f(x)-f(xph)) is a often a problem.
George White <aa056 at chebucto.ns.ca> tel: 902.426.8509
Bedford Inst. of Oceanography, Nova Scotia, Canada.
On Wed, 13 Jan 1999, Jim Lindsey wrote:
> The bug: Using pch=0 in plot or points gives squares as a
> symbol. Using it in legend leaves a blank space. (0.63.1)
> The question: I am getting various reports that R under MS-Windows and
> X-Windows/Linux on the same machine behaves very differently for nlm
> convergence in my libraries. Under Linux, convergence is easy with
> many starting values, but under MS they have to be very close to the
> MLE. Does anyone have experience with this and or an explanation?
> Is the math used different in the two systems?
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help