[R] How to do knn regression

Liaw, Andy andy_liaw at merck.com
Mon Mar 21 17:22:08 CET 2005


ksmooth() will work for you, since you only have one predictor.  There are
better choices, though, such as loess().

Andy

> From: Menghui Chen
> 
> How can I do a simple k nearest neighbor regression in R? My training
> data have 1 predictor and 1 outcome, both are numeric. I also need to
> use FPE and SC to find the optimal model. I know there is knn() in
> class package, but it's for knn classification. I also find a kknn
> package. What function should I use?
> 
> Thanks in advance!
> 
> Menghui
> 
> ______________________________________________
> 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