Statistical Methods
Fit a nondecreasing sequence with isotonic regression
Define the task
State why the underlying relationship should be nondecreasing before imposing that restriction. Fix the order of the predictor values and document how repeated predictor values are aggregated. Isotonic regression finds ordered fitted values that minimize weighted squared differences from the observations. It does not assume a particular smooth curve.
Carry out the check
For equal weights, begin with one block per observation. Whenever a left block has a greater mean than the block to its right, pool them and replace both by their combined mean. Recheck the neighboring blocks until all means are nondecreasing. Restore one fitted value for every original position. Unequal reliability or sample sizes require an explicit weighting rule.
Worked hypothetical example
For hypothetical ordered responses 1, 3, 2 and 4, the middle two observations violate the restriction. Pooling them gives fitted values 1, 2.5, 2.5 and 4 with squared-error sum 0.5. A flat block represents the constrained fit, not proof that the underlying response is exactly constant. Report the restriction, weights, pooling and intended use before extrapolating the result.
Method checked 14 November 2026 against SciPy documentation: isotonic_regression.