stat-qq

Q-Q statistic: theoretical-vs-sample pairs against a reference distribution.

Reads the sample aesthetic from the mapping; if sample is absent the statistic falls back to y. Non-numeric and none values are dropped. Output rows are sorted by sample ascending, with theoretical taken from theoretical-quantile((i + 0.5) / n, distribution) for i in 0..n. Supported reference distributions are "normal" (default), "uniform", and "exponential".

Usage

stat-qq()

Returns

Statistic object with name: "qq", consumed by geom layers.

Outputs

  • theoretical.
  • sample.

Examples

Q-Q points against a normal reference, mapping y only.

#let d = (1, 2, 3, 4, 5).map(v => (v: v))
#plot(
  data: d,
  mapping: aes(y: "v"),
  layers: (geom-qq(),),
  width: 10cm,
  height: 6cm,
)

Q-Q chart with theoretical normal quantiles on the x-axis and sample quantiles on the y-axis, showing points generated from a y-only mapping.

Q-Q chart with theoretical normal quantiles on the x-axis and sample quantiles on the y-axis, showing points generated from a y-only mapping.

Constructor form: stat: stat-qq() is equivalent to stat: "qq" with defaults.

#let d = range(1, 21).map(i => (v: i + calc.sin(i)))
#plot(
  data: d,
  mapping: aes(y: "v"),
  layers: (geom-point(stat: stat-qq(), size: 2pt), geom-qq-line(stroke: 1pt)),
  width: 10cm,
  height: 6cm,
)

Q-Q chart with theoretical quantiles on the x-axis and sample quantiles on the y-axis, points produced by stat-qq with a normal reference line overlaid.

Q-Q chart with theoretical quantiles on the x-axis and sample quantiles on the y-axis, points produced by stat-qq with a normal reference line overlaid.

See also

geom-qq, stat-qq-line.

Back to top