Re: [R] Bug in lowess

From: Frank E Harrell Jr <f.harrell_at_vanderbilt.edu>
Date: Thu 12 Oct 2006 - 13:02:40 GMT

Prof Brian Ripley wrote:
> 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).
>

Thank you Brian. It seems that no matter what is the right answer, the answer currently returned on my system is clearly wrong. lowess()$y should be constrained to be within range(y).

lowess(x,y,iter=0) provides a reasonable solution in this case; I just don't know how to automatically force iter=0.

Frank

-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Thu Oct 12 23:06:54 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 12 Oct 2006 - 13:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.