Skip to content

BCompare groups · Guide test 027

Savage scores test

Compares groups using exponential scores, emphasizing differences toward the upper end of the distribution.

Runs in CodeSplashPython (calls R) example not runR example validated

Do it in CodeSplash

In the app, set it up in Analyze with this method:

  • Kruskal–Wallis test — Do three or more independent groups differ in location (without assuming normality)?

In Kruskal–Wallis test, choose Rank scores = Savage (exponential) scores.

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · Savage scores test

3
10
0.60

Group i has true mean (i − 1) × spread.

1.00
0.050

Your data

Drag a point or use ↑/↓ to change it
Group 1 · n = 10 · mean 0.16Group 2 · n = 10 · mean 0.90Group 3 · n = 10 · mean 0.97

If H₀ were true

T = 4.79
  1. The reference: how T varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .091).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

T=(N−1)∑jnj(aˉj−aˉ)2∑i(ai−aˉ)2,a(i)=∑j=N−i+1N1j−1T = \dfrac{(N-1)\sum_j n_j(\bar a_j-\bar a)^2}{\sum_i(a_i-\bar a)^2},\qquad a(i) = \sum_{j=N-i+1}^{N}\tfrac{1}{j}-1

With your numbers

T=4.79,ν=2T = 4.79,\quad \nu = 2
a(i)a(i)
Savage (exponential) scores, large for the largest ranks

The verdict

T(2) = 4.79, p = .091

p > α = .050: compatible with H₀

Optimal for exponential-type data and scale shifts in lifetimes; the rank analog of the log-rank test without censoring.

Statistic
4.786
p-value
0.0914
Savage scores test on Group 1: n = 10; Group 2: n = 10; Group 3: n = 10: T(2) = 4.79, p = .091. The p-value is above α = .050, so the data are compatible with H0.

Savage scores test on Group 1: n = 10; Group 2: n = 10; Group 3: n = 10: T(2) = 4.79, p = .091. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: independent samples have identical distributions; alternative: a systematic shift in exponential scores.

Assumptions

Independent observations and independent groups; ordinal or quantitative measurements. The permutation null is identical group distributions. A location or median interpretation additionally needs comparable distribution shapes.

Formula

a(r)=∑s=N−r+1N1s−1T=∑jnjaˉj2(N−1)−1∑ia(Ri)2\begin{gathered}a(r)=\sum_{s=N-r+1}^{N}\frac1s-1\\[5pt] T=\frac{\sum_jn_j\bar a_j^2}{(N-1)^{-1}\sum_i a(R_i)^2}\end{gathered}

Parameters and notation

Ranks increase with observations; the displayed scores have pooled mean zero. For tied ranks average the corresponding scores.

Structure of the method

Replace pooled ranks with centered exponential-order scores and form a group score-sum statistic or its omnibus quadratic version. The increasing score sequence emphasizes upper observations. Under fixed group sizes and identical distributions, conditional permutation supplies the null distribution; a covariance-based chi-square limit supports larger samples.

Estimated and nuisance parameters

Computed quantities include pooled ranks, tie-averaged scores, group score totals, and the conditional covariance. The exponential score function is fixed by the test and does not mean an exponential distribution has been fitted to the observations. Group size and the scientific direction are design quantities.

Settings and design choices

Choose a directional two-sample or omnibus multi-group test, tie-score averaging, exact/Monte Carlo/asymptotic distribution, alpha, and the multiplicity family. If upper-tail emphasis is scientifically motivated, record that before analysis. Reversing the score convention reverses directional interpretation and should be checked against software output.

Fitting and adaptation

Rebuild pooled ranks and tied-score averages after any data change. In a custom permutation implementation, hold observed scores fixed and permute only labels allowed by the design. For censored lifetimes, use a censoring-aware survival procedure rather than treating censoring times as fully observed values in this ordinary rank test.

Sensitivity and robustness

A handful of highest ranks can drive the result, so compare the substantive tail patterns with the test's intended alternative. Heavy ties reduce score resolution. Monotone transformations preserve order but not the scientific meaning of an exponential-type alternative; this is a score test for distributional ordering, not a proof of an exponential data model.

How to use and calibrate

Use the rank permutation distribution or an asymptotic χ²k−1 quadratic score test. Two sample directional versions use a standardized score sum.

Example application

Compare positive lifetimes when an exponential type shift/scale alternative is plausible.

Interpretation and pitfalls

Watch out

The name also covers differently oriented score conventions. Check the direction of large scores and the exact implementation.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.

Python and R

Ranks/scores use all observations pooled across independent groups; the omnibus p-value is not a pairwise conclusion.

Python · invokes R

Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: coin

# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
    raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
d <- data.frame(value=c(rnorm(20),rnorm(20,.4),rnorm(20,.8)), group=factor(rep(c("A","B","C"),each=20)))
print(coin::savage_test(value~group,data=d))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
                        text=True, capture_output=True)
print(result.stdout)
if result.stderr:
    print(result.stderr)
result.check_returncode()
R

Validated — Executed successfully in the validation environment · needs coin

set.seed(2026)
d <- data.frame(value=c(rnorm(20),rnorm(20,.4),rnorm(20,.8)), group=factor(rep(c("A","B","C"),each=20)))
print(coin::savage_test(value~group,data=d))
Output
	Asymptotic K-Sample Savage Test

data:  value by group (A, B, C)
chi-squared = 9.5222, df = 2, p-value = 0.008556

Sources

Statistics guide v4 (historical):
Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 027, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT027.