Skip to content

FTime to event · Guide test 134

Hegazy–Green tests

Use discrepancies between transformed order statistics and their exponential expectations; two standard variants exist.

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:

In Exponentiality tests (battery), choose Test = Hegazy–Green T₁.

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 · Hegazy–Green tests

25
1.60

1 is the exponential (constant hazard); above 1 wear-out, below 1 early failures.

2.0

Statistic

0.050

Your data

Weibull lifetimes; shape 1 is exponential
Lifetimes · n = 25 · mean 2.07

If H₀ were true

T₁ = 0.19
  1. The reference: how T₁ varies across samples when H₀ is true, simulated: 999 exponential samples of 25 (simulated null on the shared Wichmann–Hill stream).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .239).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

T1=1n∑i∣Y(i)−qi∣,qi=−ln⁡(1−in+1)T_1=\tfrac1n\sum_i\left|Y_{(i)}-q_i\right|,\quad q_i=-\ln\left(1-\tfrac{i}{n+1}\right)

With your numbers

T=0.19,n=25T = 0.19,\qquad n = 25
qiq_i
expected exponential order statistics (approximately)
T2T_2
the squared version

The verdict

T₁ = 0.19, p = .239

p > α = .050: compatible with H₀

Q–Q plot distances from the exponential line; the null is simulated. H0 fixes no scale: every statistic uses x / x̄.

Statistic
0.193
p-value
0.2390
Hegazy–Green tests on Lifetimes: n = 25: T1 = 0.19, p = .239. The p-value is above α = .050, so the data are compatible with H0.

Hegazy–Green tests on Lifetimes: n = 25: T₁ = 0.19, p = .239. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: Xi are exponential with some common mean θ>0; H1: a departure detectable by this statistic.

Assumptions

Independent identically distributed positive, uncensored observations. The null is an exponential distribution with unknown scale and known origin zero. Censored, shifted or dependent samples need specialized versions.

Formula

T1=1n∑i∣Y(i)−qi∣T2=1n∑i(Y(i)−qi)2qi=−log⁡(1−i/(n+1))\begin{gathered}T_1=\frac1n\sum_i|Y_{(i)}-q_i|\\[5pt] T_2=\frac1n\sum_i(Y_{(i)}-q_i)^2\\[5pt] q_i=-\log(1-i/(n+1))\end{gathered}

Parameters and notation

T1 uses absolute probability-plot discrepancies; T2 uses squared discrepancies. For a known mean θ0 use Yi=Xi/θ0 instead.

Structure of the method

Compare mean-standardized ordered lifetimes with exponential probability-plot quantiles, aggregating either absolute deviations (HG1) or squared deviations (HG2). These are two explicitly related variants, with distinct statistic scales and potentially different sensitivity to a few large discrepancies.

Estimated and nuisance parameters

Estimate the unknown exponential mean and remove it through normalization. Plotting positions and theoretical unit-exponential quantiles are fixed. In a known-scale version, the external mean replaces the sample mean and changes calibration.

Settings and design choices

Choose absolute versus squared loss, plotting positions, known/composite-scale regime, significance level and simulation count. Testing both variants as separate discoveries requires a multiple-testing plan; their p-values are not independent evidence.

Fitting and adaptation

There is no neural fitting or fine-tuning stage. For an unknown-scale exponential null, exploit scale invariance or re-estimate the mean in every simulated unit-exponential sample, exactly matching the observed-data algorithm. Calibrate the prespecified tail and repeat the entire procedure after changing a tuning rule. Report simulation count and Monte Carlo uncertainty; use a plus-one randomized p-value convention for newly implemented Monte Carlo tests.

Sensitivity and robustness

The archived package routines described in the baseline apply their formula to raw inputs, so unit-scale and composite-scale testing must be distinguished. The supplied custom example correctly normalizes observed and simulated samples. Squared loss is more sensitive to a few long times; near-zero values and rounding alter plot geometry.

How to use and calibrate

Large T rejects; calibrate the exact chosen version by null simulation.

Example application

Assess departures from an exponential probability plot.

Interpretation and pitfalls

Watch out

The archived exptest implementation applies these formulas to raw input without normalization. It therefore tests unit scale unless input is normalized; unknown-scale inference must repeat normalization in simulations.

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

Both absolute and squared Hegazy–Green discrepancies are normalized by the sample mean and re-normalized in every exponential null replicate. This avoids using a known-scale reference for fitted-scale data.

Python · invokes R

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

# 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)
x<-rexp(30,rate=2)
HG<-function(x) {n<-length(x);y<-sort(x)/mean(x);q<--log(1-seq_len(n)/(n+1));c(HG1=mean(abs(y-q)),HG2=mean((y-q)^2))}
T<-HG(x);B<-999;null<-replicate(B,HG(rexp(length(x))))
print(data.frame(statistic=T,p=(1+rowSums(null>=T))/(B+1)))
"""
# 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 Base/standard library

set.seed(2026)
x<-rexp(30,rate=2)
HG<-function(x) {n<-length(x);y<-sort(x)/mean(x);q<--log(1-seq_len(n)/(n+1));c(HG1=mean(abs(y-q)),HG2=mean((y-q)^2))}
T<-HG(x);B<-999;null<-replicate(B,HG(rexp(length(x))))
print(data.frame(statistic=T,p=(1+rowSums(null>=T))/(B+1)))
Output
    statistic     p
HG1 0.2142751 0.102
HG2 0.1055363 0.212

Sources

  • exptest — exptest · hegazy1.exp.testAuthor documentation/source reviewed: exptest 1.2.rdrr.io
  • exptest — exptest · hegazy2.exp.testAuthor documentation/source reviewed: exptest 1.2.rdrr.io
  • hegazy1.exp.testrdrr.io
  • hegazy2.exp.testrdrr.io
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 134, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT134.