Spiegelhalter's z Statistic Calculator

Inputs

Spiegelhalter's z statistic-1.3526
Two-sided p-value0.1762
Standard error (sqrt of variance sum)9.2412
Mean calibration term per case-0.0313
How this was calculated
  1. Inputs: sum of (y - p)(1 - 2p) = -12.5, sum of (1 - 2p)^2 p(1 - p) = 85.4, over 400 cases.
  2. The standard error is the square root of the variance sum: sqrt(85.4) = 9.2412.
  3. z = -12.5 / 9.2412 = -1.3526, standard normal under the null of perfect calibration.
  4. The two-sided p-value is 0.1762.

A probabilistic forecaster - a risk model, a weather service, a survival predictor - makes a claim on every case: this one at 0.3, that one at 0.8. Calibration asks whether the claims come true at the stated rates. Spiegelhalter's z, proposed in 1986 for verifying clinical predictions, compresses the answer into one standardised sum: over all cases, add (y - p)(1 - 2p), divide by the square root of its variance sum, and read the result against the normal distribution. This calculator takes the two sums and the case count and returns z with its two-sided p-value.

Worked examples

Slight under-confidence

(-12.5 · 85.4 · 400)

Spiegelhalter's z statistic-1.3526
Two-sided p-value0.1762
Standard error (sqrt of variance sum)9.2412
Mean calibration term per case-0.0313

Significant miscalibration

(18.6 · 64.2 · 250)

Spiegelhalter's z statistic2.3214
Two-sided p-value0.0203
Standard error (sqrt of variance sum)8.0125
Mean calibration term per case0.0744

Well calibrated

(1.8 · 120.5 · 600)

Spiegelhalter's z statistic0.1640
Two-sided p-value0.8698
Standard error (sqrt of variance sum)10.9772
Mean calibration term per case0.0030

Verifying probabilistic forecasts

Discrimination and calibration are different virtues. A model can rank patients beautifully while its probabilities are systematically too timid or too bold, and ranking statistics will never notice. Spiegelhalter built his test for the second virtue, originally to check the survival forecasts clinicians quoted to individual patients. The test statistic is a score test - the derivative of the Brier score's likelihood at the point of perfect calibration - which is why it detects the specific failure of probabilities drifting away from outcomes rather than mere noisiness.

Each case contributes (y - p)(1 - 2p), and the factor (1 - 2p) is the clever part. For a prediction near 0.5 the factor vanishes: a coin-flip prediction cannot be miscalibrated in a direction, so it earns almost no vote. For confident predictions the factor is large, and an outcome that contradicts a confident prediction - the event that was priced as nearly impossible and happened anyway - votes heavily against the forecaster. The test listens hardest exactly where overconfidence lives.

  • A score test of perfect calibration for probabilistic forecasts
  • Confident wrong predictions weigh the most
  • Standard normal under the null of calibration
  • The calibration companion to the Brier score

The calibration term (y - p)(1 - 2p)

The first worked example aggregates 400 cases into a calibration sum of -12.5 and a variance sum of 85.4. The negative sum leans one way - outcomes fell short of predictions on the confident side more often than they exceeded them - but the test's question is whether the lean is larger than chance allows. The mean calibration term per case is -0.0313, a small average lean, and whether it signifies depends entirely on the spread of the terms, which is what the variance sum carries.

The second example's sum of 18.6 over 250 cases leans the other way, predictions running behind outcomes on the confident side - the signature of an under-confident forecaster whose high predictions were not high enough. Its mean term per case is 0.0744, more than twice the first example's in absolute value, on fewer cases. Aggregation is the test's practical demand: the two sums must be accumulated case by case from the forecaster's own predictions and the realised outcomes, and no summary of the predictions alone can substitute.

Worked examples

Example 1: Sum of (y - p)(1 - 2p) over cases -12.5; Sum of (1 - 2p)^2 p(1 - p) over cases 85.4; Number of cases 400. Spiegelhalter's z statistic = -1.3526. Supporting values: Two-sided p-value 0.1762; Standard error (sqrt of variance sum) 9.2412; Mean calibration term per case -0.0313. Inputs: sum of (y - p)(1 - 2p) = -12.5, sum of (1 - 2p)^2 p(1 - p) = 85.4, over 400 cases. The standard error is the square root of the variance sum: sqrt(85.4) = 9.2412. z = -12.5 / 9.2412 = -1.3526, standard normal under the null of perfect calibration. The two-sided p-value is 0.1762.

Example 2: Sum of (y - p)(1 - 2p) over cases 18.6; Sum of (1 - 2p)^2 p(1 - p) over cases 64.2; Number of cases 250. Spiegelhalter's z statistic = 2.3214. Supporting values: Two-sided p-value 0.0203; Standard error (sqrt of variance sum) 8.0125; Mean calibration term per case 0.0744. Inputs: sum of (y - p)(1 - 2p) = 18.6, sum of (1 - 2p)^2 p(1 - p) = 64.2, over 250 cases. The standard error is the square root of the variance sum: sqrt(64.2) = 8.0125. z = 18.6 / 8.0125 = 2.3214, standard normal under the null of perfect calibration. The two-sided p-value is 0.0203.

Example 3: Sum of (y - p)(1 - 2p) over cases 1.8; Sum of (1 - 2p)^2 p(1 - p) over cases 120.5; Number of cases 600. Spiegelhalter's z statistic = 0.1640. Supporting values: Two-sided p-value 0.8698; Standard error (sqrt of variance sum) 10.9772; Mean calibration term per case 0.0030. Inputs: sum of (y - p)(1 - 2p) = 1.8, sum of (1 - 2p)^2 p(1 - p) = 120.5, over 600 cases. The standard error is the square root of the variance sum: sqrt(120.5) = 10.9772. z = 1.8 / 10.9772 = 0.1640, standard normal under the null of perfect calibration. The two-sided p-value is 0.8698.

Standardising the sum

Under perfect calibration each term has mean zero and variance (1 - 2p)^2 p(1 - p), so the variance sum is the natural yardstick: the standard error is its square root. The first example's is 9.2412, the second's 8.0125, the third's 10.9772 on 600 cases. Dividing gives z: -1.3526, 2.3214 and 0.1640 respectively. Note what the standardisation does to the second example - its raw sum of 18.6 is only half again the first example's 12.5 in size, but against a smaller standard error it standardises to a much larger z. Raw sums mislead; the ratio is the test.

The normal approximation behind the p-value is a large-sample one, comfortable at the case counts of the worked examples - 400, 250 and 600 - and increasingly trustworthy as the variance sum grows. With very few cases, or with predictions piled at the extremes where individual terms dominate, the approximation coarsens and an exact or simulated null is the careful route. The calculator reports the standard error itself so the user can see how much information the standardisation is standing on.

Reading z and its p-value

The readings are the familiar ones. The first example's z of -1.3526 gives a p-value of 0.1762: a lean of that size arises under perfect calibration often enough that the forecaster keeps the benefit of the doubt. The second example's 2.3214 gives 0.0203 - evidence, at the conventional line, that the probabilities are miscalibrated, with the positive sign pointing at under-confidence. The third example's 0.1640 and p-value of 0.8698 are what a calibrated forecaster usually looks like: nothing to explain.

A rejection is a beginning, not a verdict. The z test says the probabilities and outcomes disagree systematically; it does not say where - in the high range, the low range, one subgroup - and the follow-up is to group the cases and compare mean predictions with event rates group by group. What z contributes is the discipline of a single honest number first, so that the grouping exercise starts from an established fact rather than from a suspicious-looking corner of a calibration plot.

The statistic also sits inside a larger decomposition worth knowing. The Brier score for a set of forecasts splits into reliability, resolution and uncertainty terms; Spiegelhalter's z is the standardised reliability piece - the part that punishes probabilities for being systematically off, as opposed to merely uninformative. A forecaster can therefore post a fine Brier score on resolution while failing z on reliability, and the two failures have different cures: sharper information for the first, honest recalibration for the second. The z test's job in the kit is to make sure the second failure is never hidden by the first's success.

Recalibration, when z demands it, is usually simple in shape: confident predictions pulled toward the centre, or a systematic tilt corrected. The test then re-runs on the next cohort of cases - the 400-case audit repeated, not the same cases refitted - because a z computed on the data that performed the recalibration proves nothing. Verification is a habit, not an event, and Spiegelhalter's statistic was designed for repetition: cheap to accumulate, honest about direction, and unimpressed by reputation.

Spiegelhalter vs Hosmer-Lemeshow

The Hosmer-Lemeshow test is the calibration check most software prints by default, and it works by binning: group the cases, usually into ten bands of predicted risk, and compare observed with expected counts by chi-square. Its weaknesses are the binning's - the result moves with the number of groups and their boundaries, and power leaks away in the grouping. Spiegelhalter's z uses no bins at all: every case enters with its own prediction, the weighting is fixed by the score-test mathematics, and the result is a signed statistic that also says which direction the miscalibration leans.

The two tests are complements in practice - Hosmer-Lemeshow's grouped table is the better diagnostic display once a problem is established, and Spiegelhalter's z is the sharper first question. Together with the Brier score, which prices calibration and discrimination in one number and has its own page here, they form the standard verification kit for probabilistic predictions that Spiegelhalter's 1986 paper effectively founded. A forecaster whose z sits near zero across successive audits has earned the right to have its probabilities quoted as probabilities.

FAQs

What z statistic does the first worked example give?

-1.3526: a calibration sum of -12.5 against a standard error of 9.2412 over 400 cases.

What p-value does the first example give?

0.1762 - no significant evidence of miscalibration.

What standard error does the first example have?

9.2412, the square root of the variance sum of 85.4.

What mean calibration term per case does the first example have?

-0.0313 - a small average lean of outcomes below predictions.

What z does the miscalibrated second example give?

2.3214, with a p-value of 0.0203 - significant, and positive: the forecaster was under-confident.

What z do the well-calibrated 600 cases of the third example give?

0.1640, with a p-value of 0.8698 - nothing to explain.

Sources

Related calculators

Brier Score Calculator
Compute the Brier score of probability forecasts from the summed squared errors, with the climatology reference score and the Brier skill score against it.
P-Value Calculator from Z-Score
Turn a z-score into a p-value for left-tailed, right-tailed and two-tailed tests, using the standard normal distribution.
Net Reclassification Improvement (NRI) Calculator
The net reclassification improvement of a new risk model: upward and downward movement in events and non-events, with Pencina's standard error, z statistic and p-value.