统计问题:R 中的核平滑 [英] Statistics Question: Kernel Smoothing in R

查看:39
本文介绍了统计问题:R 中的核平滑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种形式的数据:

 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

我目前正在使用以下代码绘制 x 与 y 的核平滑密度估计:

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 )

我只想绘制 x 与平滑 (y) 值的关系图,即 ## Heading ##

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

但是,ksmooth 文档 表明这不是最好的内核平滑包:

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

这个功能是纯粹实现的为了与 S 兼容,虽然它远不及 S 慢功能.更好的内核平滑器是在其他包中可用.

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?

推荐答案

如果你只是想要一个 x 与平滑 (y) 的图",那么我建议考虑包 中的 loess>stats - 简单、快速且有效.相反,如果您真的想要基于内核平滑的回归,那么您可以尝试包 KernSmooth 中的 locpolynp<包中的 npreg/代码>.

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.

这篇关于统计问题:R 中的核平滑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆