1.17 Visualizing Distributions Example

Numeric Distributions

ECDFs

A set of three empirical CDFs drawn from 300 samples of a gamma(2, 2) distribution, a normal (9, 3) distribution, and a poisson(10) distribution. The gamma and normal eCDFs appear relatively smooth, while the poisson eCDF is jagged.

  • 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

A set of three histograms drawn from 300 samples of a gamma(2, 2) distribution, a normal (9, 3) distribution, and a poisson(10) distribution. The mean, median, and mode of each distribution are marked with vertical lines and labels. The gamma distribution is skewed, with mode < median < mean. The normal distribution is roughly symmetric, with mode,  median, and mean approximately equal. The poisson distribution has odd gaps, and the mode is slightly lower than the mean and median, which are equal.

  • Easy to see distribution center and spread
  • Sensitive to bin width/number of bins

Histograms

A set of three histograms drawn from 300 samples of a gamma(2, 2) distribution, a normal (9, 3) distribution, and a poisson(10) distribution. The mean, median, and mode of each distribution are marked with vertical lines and labels. The gamma distribution is skewed, with mode < median < mean. The normal distribution is roughly symmetric, with mode,  median, and mean approximately equal. The poisson distribution has gaps between integer values, and the mode is slightly lower than the mean and median, which are equal.

  • Easy to see distribution center and spread
  • Sensitive to bin width/number of bins
    • Extra-sensitive if data are discrete or rounded

Density Plots

A set of three density curves drawn from 300 samples of a gamma(2, 2) distribution, a normal (9, 3) distribution, and a poisson(10) distribution. The mean, median, and mode of each distribution are marked with vertical lines and labels. The gamma distribution is skewed, with mode < median < mean. The normal distribution is roughly symmetric, with mode,  median, and mean approximately equal. The poisson distribution has a mode which is slightly lower than the mean and median, which are equal.

  • Smoothed out version of a histogram
  • Masks rounded/discrete variables

Density Plots

A set of three density curves drawn from 300 samples of a gamma(2, 2) distribution, a normal (9, 3) distribution, and a poisson(10) distribution. The mean, median, and mode of each distribution are marked with vertical lines and labels. The gamma distribution is skewed, with mode < median < mean. The normal distribution is roughly symmetric, with mode,  median, and mean approximately equal. The poisson distribution has a mode which is slightly lower than the mean and median, which are equal.

  • 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