[R] FW: Kernel smoothing with bandwidth which varies with x

1 view
Skip to first unread message

IOANNA

unread,
May 23, 2013, 12:10:58 PM5/23/13
to r-h...@r-project.org
Hello all,

I would like to use the Nadaraya-Watson estimator assuming a Gaussian
kernel: So far I sued the
library(sm)
library(sm)
x<-runif(5000)
y<-rnorm(5000)
plot(x,y,col='black')
h1<-h.select(x,y,method='aicc')
lines(ksmooth(x,y,bandwidth=h1))

which works fine. What if my data were clustered requiring a bandwidth that
varies with x? How can I do that?

Thanks in advance,
Ioanna

______________________________________________
R-h...@r-project.org 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.

Uwe Ligges

unread,
May 23, 2013, 4:15:02 PM5/23/13
to IOANNA, r-h...@r-project.org


On 23.05.2013 18:10, IOANNA wrote:
> Hello all,
>
> I would like to use the Nadaraya-Watson estimator assuming a Gaussian
> kernel: So far I sued the
> library(sm)
> library(sm)
> x<-runif(5000)
> y<-rnorm(5000)
> plot(x,y,col='black')
> h1<-h.select(x,y,method='aicc')
> lines(ksmooth(x,y,bandwidth=h1))
>
> which works fine. What if my data were clustered requiring a bandwidth that
> varies with x? How can I do that?

I'd start with trying to transform x so that the bandwidth can be fixed.

Uwe Ligges
Reply all
Reply to author
Forward
0 new messages