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, WN and Ripley, BD (2002) Modern Applied Statistics with S. New York: Springer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.