stat-qq-line

Q-Q reference-line statistic: two endpoints of the IQR-fitted line.

Slope is (q3 - q1) / (t3 - t1) from the sample’s 25th and 75th type-7 quantiles divided by the corresponding theoretical quantiles of the reference distribution, and intercept is q1 - slope * t1. Endpoints span the theoretical range that stat-qq would emit for the same n and reference distribution. Supported reference distributions are "normal" (default), "uniform", and "exponential".

Usage

stat-qq-line()

Returns

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

Outputs

  • theoretical.
  • sample.

Examples

Reference line under geom-qq for a normal Q-Q plot.

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

Q-Q chart with theoretical normal quantiles on the x-axis and sample quantiles on the y-axis, points sitting on a reference line drawn under the QQ layer.

Q-Q chart with theoretical normal quantiles on the x-axis and sample quantiles on the y-axis, points sitting on a reference line drawn under the QQ layer.

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

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

Q-Q chart with theoretical quantiles on the x-axis and sample quantiles on the y-axis, with a red reference line through the first and third quartiles.

Q-Q chart with theoretical quantiles on the x-axis and sample quantiles on the y-axis, with a red reference line through the first and third quartiles.

See also

geom-qq-line, stat-qq.

Back to top