StudentizedRange (ANOVA v0.7.1)

Copy Markdown View Source

Studentized range distribution for Tukey's HSD.

Provides:

  • ptukey(q, k, df) -> CDF P(Q ≤ q) for k means and residual df
  • qtukey(p, k, df) -> upper-tail quantile q such that P(Q ≤ q) = p

The implementation follows the standard double-integral representation: F(q; k, ν) = C * ∫{s=0}^{∞} s^{ν-1} φ(√ν s) ∫{z=-∞}^{∞} φ(z) [Φ(z + q s) - Φ(z)]^{k-1} dz ds

with C = √(2π) k ν^{ν/2} / (Γ(ν/2) * 2^{(ν/2 - 1)}).

Special case ν=∞ uses: F(q; k) = k ∫ φ(z) [Φ(z+q) - Φ(z)]^{k-1} dz

References:

  • Copenhaver & Holland (1988), J. Stat. Comput. Simul. (distribution of the maximum studentized range).
  • R ‘stats’ :: ptukey/qtukey documentation (algorithmic details and references).
  • Wikipedia: “Studentized range distribution” (integral forms).

Summary

Functions

CDF of the studentized range: P(Q ≤ q) for k means and residual df.

Quantile function for the studentized range: q such that P(Q ≤ q) = p.

Types

df()

@type df() :: pos_integer() | :infinity

k()

@type k() :: pos_integer()

Functions

ptukey(q, k, df, opts \\ [])

CDF of the studentized range: P(Q ≤ q) for k means and residual df.

  • q — nonnegative real
  • k — number of group means (k ≥ 2)
  • df — residual degrees of freedom (integer ≥ 1) or :infinity

Options:

  • :inner_nodes (default 16) — Gauss–Legendre nodes for inner z-integral
  • :outer_nodes (default 16) — Gauss–Legendre nodes for outer s-integral
  • :z_limit (default 8.0) — truncate z ∈ [−L, L]
  • :s_limit (default 6.0) — truncate s ∈ [0, L] (effective for moderate/large ν)
  • :panels (default 32) — panel count per dimension (adaptive-like)

Returns a float in [0,1].

qtukey(p, k, df, opts \\ [])

Quantile function for the studentized range: q such that P(Q ≤ q) = p.

  • p — probability in (0,1)
  • k — number of means
  • df — residual df (integer ≥ 1) or :infinity

Options (passed to ptukey/4 and to the root finder):

  • :tol (default 1.0e-8) — absolute tolerance for p
  • :max_iter (default 100)
  • as in ptukey/4: :inner_nodes, :outer_nodes, :z_limit, :s_limit, :panels

Returns a positive float.