[R] loess question
Saurav Pathak
saurav at sas.upenn.edu
Fri Oct 7 22:09:03 CEST 2011
Hi All,
I am trying to use loess to smooth a 2D image, and also obtain the
standard error for every pixel. I see that the standard error does not
make sense. For example, running the following:
library(stats)
x <- array(c(1:100), dim=c(100,100))
y <- t(x)
v <- exp(-((x-50)^2+(y-50)^2)/30^2)
s <- v*0.02
g_noise <- rnorm(10000, mean = 0, sd = s)
f <- v + g_noise
f.loess <- loess(f ~ x + y, span=0.1, data.frame(x=c(x),y=c(y),f=c(f)))
f.predict <- predict(f.loess, data = data.frame(x = c(x), y = c(y), f =
c(f)), span = 0.1,se=TRUE)
image(1:100,1:100,matrix(f.predict$se,nrow=100))
I get an image of the standard error that has peaks at regular grid
nodes. Shouldn't I expect to see roughly the same error that I put in
(in this case g_noise)? I notice that the noise peaks move apart for
higher span values.
Thanks for your help!
Saurav
More information about the R-help
mailing list