R/stat_density_confidence.R
stat_density_confidence.RdThis function creates a normal theory based confidence envelope for the empirical density. The idea came from functions written by Bowman and Azzalini.
Default list of aesthetic mappings to use for plot.
The data to be displayed in this layer.
A normal kernel function is used and h is its standard deviation. If this parameter is
omitted, a normal optimal smoothing parameter is used.
Fill color for the confidence envelope. The default is fill="skyblue"
The model to draw the confidence envelope for. The default is model="none" which creates the
confidence envelope from the data. Using model="normal" creates the confidence envelope based on a normal distribution.
Other arguments passed to ggplot2::layer().
These stat uses geom_ribbon() so support the same aesthetics: alpha, colour, fill,
linetype, group, and size.
ggplot(mtcars, aes(x = mpg)) +
stat_density_confidence(model = "normal") +
geom_density()