[R] Bug in lowess
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Oct 12 13:43:11 CEST 2006
On Thu, 12 Oct 2006, Gavin Simpson wrote:
> On Wed, 2006-10-11 at 22:29 -0500, Frank E Harrell Jr wrote:
>> x <- c(0,7,8,14,15,120,242)
>> y <- c(122,128,130,158,110,110,92)
>>
>> lowess(x,y)
>>
>> $x
>> [1] 0 7 8 14 15 120 242
>>
>> $y
>> [1] 122.0000 128.0000 132.2857 158.0000 110.0000 -4930.0000
>> 110.0000
>
> Same behaviour here on a more recent R (below), and I recall a posting
> for a year or so back that reported similar behaviour in the then
> current version of R.
Actually, it is system-dependent as I get (on x86_64)
> lowess(x,y, iter=3)
lowess(): ns = 4
cmad = 0.25589
cmad = 0
cmad = 0.00583385
$x
[1] 0 7 8 14 15 120 242
$y
[1] 128.0000 128.0000 132.2857 158.0000 110.0000 109.9990 110.0000
having turned DEBUG_lowess on. So the issue is finite-precision
arithmetic, once again.
It seems rather a moot point as to what the right answer actually is
here, and even if that found by Frank is indeed wrong, as lowess() is
defined by an algorithm. Perhaps the best one can hope for is a good
approximation to what the algorithm would give in infinite-precision
arithmetic (having defined what should happen if cmod is zero).
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list