1.17 Visualizing Distributions Example
ECDFs
- Shows all of the data in the distribution
- Continuous variables will look relatively smooth for large enough \(n\) (plots 1, 2)
- Discrete variables will have “steps” (plot 3)
- Hard to see the mean, variability, range
Histograms
- Easy to see distribution center and spread
- Sensitive to bin width/number of bins
Histograms
- Easy to see distribution center and spread
- Sensitive to bin width/number of bins
- Extra-sensitive if data are discrete or rounded
Density Plots
- Smoothed out version of a histogram
- Masks rounded/discrete variables
Density Plots
- Smoothed out version of a histogram
- Masks rounded/discrete variables
- With smaller bandwidth/adjustment, discrete variables look like zigzags.
- Adjust bandwidth using
geom_density(adjust=XXX)
- Try values of XXX of 0.5, 1.5 to start
Box Plots
- Box:
- lower: 25th percentile
- upper: 75th percentile
- middle: median, 50th percentile
- Whiskers:
- smallest observation that is greater than or equal to (lower hinge - 1.5 * (upper - lower))
- largest observation that is less than or equal to (upper hinge + 1.5 * (upper - lower))
- Outliers: anything not covered by the whiskers are shown as individual points
Violin Plots
- Density curve plotted vertically, then mirrored
- Often shown with a boxplot (or quantile lines) overlaid on top
