Statistical Methods

Fit a Trend with Repeated Median Slopes

Define the research task

Use repeated-median fitting as a prespecified sensitivity analysis for a roughly linear relationship where a few unusual observations could dominate least squares. Inspect the scatterplot first and preserve unusual observations for investigation. A robust line does not repair confounding, nonlinearity, dependence or measurement error in the predictor.

Work through the check

  1. Keep actual x coordinates, particularly when observations are irregularly spaced.
  2. For each point, calculate slopes to every other point.
  3. Take a median within each point, then a median across those medians.
  4. Use median(y − slope × x) for the hierarchical intercept.
  5. Compare fitted values and residual patterns with the scientific model.

This is not the median of all pooled pairwise slopes. The browser tool requires distinct x values and does not estimate uncertainty. Record the intercept convention so another analyst can reproduce the fit.

Hypothetical example and reporting

For hypothetical x = 0,1,2,3,4 and y = 1,3,5,7,100, the repeated-median slope is 2 and hierarchical intercept is 1. The line fits the first four observations; the last residual is 91. That discrepancy still needs investigation. Report the unusual point and the sensitivity analysis, rather than presenting the robust fit as evidence that the point is erroneous.

Source and verification

Method checked 26 November 2026 against SciPy primary documentation: stats.siegelslopes. Examples are synthetic; this page does not assert human expert approval.

Open the repeated median line fit.

Download the editable plain-text worksheet.

Related reading

Reading path: Analyze data. Guide 224 of 232. Choose any guide to suit your project.

Statistical Methods

Distinguish Mood\u2019s Scale Test from a Median Test

Practical steps and a worked example: Record the scientific null and avoid confusing two tests with similar names.

Statistical Methods

Check Local Median Filtering Before Smoothing Research Images

Practical steps and a hypothetical example: Inspect local rank filtering and its boundary assumptions.

Browse this reading pathTools for this stageGuides and downloads for this stage