Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Statistics Question: Kernel Smoothing in R

Tags:

r

statistics

I have data of this form:

 x    y
 1    0.19
 2    0.26 
 3    0.40
 4    0.58
 5    0.59
 6    1.24
 7    0.68
 8    0.60
 9    1.12
10    0.80
11    1.20
12    1.17
13    0.39

I'm currently plotting a kernel-smoothed density estimate of the x versus y using this code:

   smoothed = ksmooth( d$resi, d$score, bandwidth = 6 )
   plot( smoothed )

I simply want a plot of the x versus smoothed(y) values, which is ## Heading ##

However, the documentation for ksmooth suggests that this isn't the best kernel-smoothing package available:

This function is implemented purely for compatibility with S, although it is nowhere near as slow as the S function. Better kernel smoothers are available in other packages.

What other kernel smoothers are better and where can these smoothers be found?

like image 545
James Thompson Avatar asked Jun 11 '10 18:06

James Thompson


1 Answers

If you "simply want a plot of the x versus smoothed(y)", then I recommend considering loess in package stats - it's simple, fast and effective. If instead you really want a regression based on kernel smoothing, then you could try locpoly in package KernSmooth or npreg in package np.

like image 60
nullglob Avatar answered Nov 08 '22 13:11

nullglob