如何更改R中密度图中使用的内核带宽 [英] How do I change the kernel bandwidth used in a density plot in R

查看:357
本文介绍了如何更改R中密度图中使用的内核带宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查看密度图中内核使用的带宽,以及如何指定要使用的带宽?我试过了

$ $ p $ $ $ $ $ $ $ $ $ $ $ $ $ $

$ b

没有运气。

解决方案

stat_geom 利用调整参数将乘数应用于ggplot计算的最佳带宽,参见 c> density()的文档。请尝试:

ggplot(mtcars,aes(mpg))+ geom_density()+ stat_density(adjust = 2)



我根据平滑内核的标准偏差确定计算出的最佳带宽 - 您需要询问Venables ,WN和Ripley,BD(2002)与S.New York的现代应用统计:Springer。

How do I see what bandwidth gets used for kernels in a density plot and how do I specify a bandwidth to be used? I tried

ggplot(mtcars,aes(mpg))+geom_density(bw=1)

with no luck.

解决方案

stat_geom utilises the adjust argument to apply a multiplier to the optimal bandwidth that ggplot calculates see documentation for density(). Try:

ggplot(mtcars,aes(mpg))+geom_density() + stat_density(adjust = 2)

I gather to determine the calculated optimal bandwidth - based on "the standard deviation of the smoothing kernel" - you'll need to interrogate Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. New York: Springer.

这篇关于如何更改R中密度图中使用的内核带宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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