[R] loess problems

Liaw, Andy andy_liaw at merck.com
Sat Feb 5 22:17:02 CET 2005


The problem is that 90% of your data sit on the boundary.  Loess is a
nearest neighbor smoother (using (100 x span) % of the data to estimate at
each point).  If you call loess() directly with span=2/3 (the default in
scatter.smooth), or something smaller than about 0.91, you'll see that it
has trouble.   

Strangely, if you set span=.8, scatter.smooth() will also complain, but not
at the default span...  (Re-generating the data yet again does trigger the
warnings, so seems like it does catches things some of the time.)

For your second example, I think loess becomes undefined when the span is
set too small (and 1/n is surely too small):  You are asking the algorithm
to take the nearest 1/n of the data to do the smooth.  You would think that
should just mean _the_ nearest data point, but the problem is:

> n <- 100
> 1 / n < 1
[1] TRUE

so you're asking the algoithm to take fewer than 1 data point to estimate at
each point.  The warnings you see for that example is pointing you in the
right direction.

Andy


> From: Jean Eid
> 
> I have a problem either understanding what loess is doing or 
> that loess
> has a problem itself.
> 
> As the x-axis variables become more concentrated on a 
> particular point,the
> estimated loess tends to zero????. the examples below show what i am
> talking about,  why is that? my intution tells me
> that it should tend to the mean of the variable which is been 
> smoothed.
> 
> Here's a worked up example
> 
> x <- c(seq(0,100), rep(100,1000))
> y <- rnorm(length(x), mean=10, sd=2)
> scatter.smooth(x,y)
> 
> 
> 
> Although it does give warnings, I don't understand why it is 
> giving the
> estimate as zero.
> 
> 
> another example would be
> 
> x <- seq(0,100)
> y <- rnorm(length(x), mean=50, sd=2)
> scatter.smooth(x,y, span=1/length(x))
> 
> 
> shoudn't this give just the points at which the smoothing algorithm is
> applied?
> 
> 
> 
> thank you
> 
> ______________________________________________
> R-help at 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
> 
>




More information about the R-help mailing list