13A.14 Histogram, density, ECDF, and Q-Q geoms
These four geoms describe one numeric distribution from complementary perspectives. A histogram counts values in bins. Density draws a smoothed estimate using Silverman's bandwidth. ECDF shows the fraction at or below each observed value. Q-Q compares ordered observations with theoretical normal quantiles.
--nbins defaults to 30; --binwidth overrides it. Bin choices can create or conceal apparent modes, so inspect more than one reasonable specification. --y-stat count|density|percent changes the vertical scale. Density is smooth but does not preserve raw counts. ECDF preserves all ranks and requires no bin or bandwidth, making it valuable for small-to-medium samples.

The Q-Q reference line helps assess gross departures from normal shape. It is not a formal normality decision and does not account for ETA shrinkage, uncertainty, or repeated records. In the teaching gallery, CWRES rows are observation-level; ETA distributions are reduced to one row per subject.
Colour/fill groups can be stacked, dodged, filled, or overlaid with --position. Identity overlays require transparency and consistent bins. Percent displays need a stated denominator, especially when groups have unequal N.
A useful novice sequence is histogram first, ECDF second, and Q-Q only after verifying the row grain. The histogram makes units and obvious gaps tangible; the ECDF reveals exact rank accumulation without smoothing; the Q-Q view then asks a narrower distributional question. Density is best treated as an optional presentation layer, not the primary evidence.
Common mistakes
- Selecting bins that manufacture a preferred shape.
- Comparing density heights as subject counts.
- Calling Q-Q alignment proof of model adequacy.
- Repeating subject-level values on every observation row.
Checklist
- Confirm the row grain.
- Vary bins or inspect ECDF alongside histogram.
- State count, density, or percent scale.
- Report group N and denominator.
- Interpret Q-Q tails with shrinkage and sample size in mind.
Further reading
See subject distributions, positions and bars, statistics, and validation boundaries.