How do I change the kernel bandwidth used in a density plot in R

后端 未结 1 1569
长发绾君心
长发绾君心 2021-01-04 02:16

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_densit         


        
相关标签:
1条回答
  • 2021-01-04 02:36

    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.

    0 讨论(0)
提交回复
热议问题