Compare paired device readings with signed bias, agreement limits and a check for magnitude-dependent error.
Bland–Altman plots: assess paired measurement agreement
Pair the same specimen under both methods
A method-agreement plot starts with two readings of the same item under conditions that make comparison meaningful. Put their mean on the horizontal axis and the signed difference, new instrument minus reference instrument, on the vertical axis. A scatterplot or high correlation between devices can coexist with a large systematic offset, so correlation is not an agreement test. Define the acceptable difference in the original unit before seeing the result. For a temperature probe, an average offset of 0.8 degrees may matter or not depending on the process tolerance; a statistically precise estimate does not make an operationally unsafe offset acceptable. Paired-change charts show each item's two readings, while this plot concentrates on the distribution of pairwise error across the measurement range.
Compute bias and descriptive limits
The horizontal reference line is the mean signed difference, or bias. Under assumptions including approximately stable difference variance and a suitable difference distribution, conventional agreement limits are bias plus or minus 1.96 sample standard deviations of differences. Those lines describe the spread expected for individual differences under the model. They are not confidence intervals for the mean bias and are not a pass/fail tolerance supplied by the process owner. Report the number of pairs, direction of subtraction and raw units with the limits. Interval labeling matters here: a reader must be able to tell agreement limits from uncertainty about where those limits lie. A small sample makes estimated limits unstable.
Look for error that changes with magnitude
A fan-shaped cloud suggests that larger measurements have greater absolute disagreement; a sloped pattern suggests proportional bias. One global pair of horizontal limits can then misrepresent both ends of the range. Inspect residual patterns and consider a justified transformation or a model in which spread depends on magnitude. Do not automatically use percent difference: dividing by a near-zero mean can explode, and a ratio may be inappropriate for values that cross zero. Regression overlays can reveal a trend, but a line drawn through differences is only descriptive until its assumptions and uncertainty are examined. Mark outliers for investigation without quietly deleting them.
Respect independent units and coverage
Repeated measurements from the same machine are correlated. Treating 47 repeated readings from one unit as 47 independent machines understates uncertainty. Choose a design that separates repeatability within each method from agreement between methods, or analyze at the proper unit. Check whether pairs cover the full operating range; limits estimated from a narrow band cannot be claimed for extreme values never sampled. An accessible table should list specimen ID, both values, pair mean, signed difference and any excluded or missing reading. An export manifest should preserve calibration date, units, method versions and the subtraction direction, because reversing that direction changes the sign of bias and both limit labels.
Worked contract
from math import sqrt, isfinite
def agreement_summary(pairs: list[tuple[str, float, float]]):
identifiers = [specimen_id for specimen_id, _, _ in pairs]
if len(pairs) < 2 or len(set(identifiers)) != len(pairs) or any(not key for key in identifiers):
raise ValueError("at least two uniquely identified pairs are required")
if any(not isfinite(reference) or not isfinite(candidate)
for _, reference, candidate in pairs):
raise ValueError("all paired readings must be finite")
points = [(specimen_id, (reference + candidate) / 2,
candidate - reference)
for specimen_id, reference, candidate in pairs]
bias = sum(difference for _, _, difference in points) / len(points)
variance = sum((difference - bias) ** 2
for _, _, difference in points) / (len(points) - 1)
spread = sqrt(variance)
return points, bias, (bias - 1.96 * spread, bias + 1.96 * spread)
probe_pairs = [("batch-47", 41.0, 42.0),
("batch-59", 54.0, 55.0),
("batch-83", 63.0, 66.0)]
points, bias, limits = agreement_summary(probe_pairs)
assert points == [("batch-47", 41.5, 1.0),
("batch-59", 54.5, 1.0),
("batch-83", 64.5, 3.0)]
assert abs(bias - 5 / 3) < 1e-12
assert limits[0] < 0 < limits[1]Performance and operating cost
For N pairs, constructing points and calculating sample variance each take O(N) time. The returned plot table takes O(N) space; streaming just the bias and variance is possible with O(1) extra space when individual points are not needed. The three-pair check fixes the sign convention and sample-variance denominator. It is too small to justify operational agreement limits and does not account for repeated measures or magnitude-dependent spread.
Common Mistakes
- Calling high correlation proof that two methods agree.
- Confusing agreement limits for individual differences with confidence limits around mean bias.
- Reversing the subtraction direction between chart and report.
- Counting repeated readings from one item as independent specimens.
Validation drill
Pair 59 items across two measurement devices. State a tolerable difference first, then plot signed differences, check for magnitude-dependent spread and report which items fall outside that tolerance.
