Robust regression calculator
The page remains single-column, while the calculator inputs use three columns on large screens, two on smaller screens, and one on mobile.
Example data table
| # | X | Y | Comment |
|---|---|---|---|
| 1 | 1.00 | 1.20 | Regular point |
| 2 | 2.00 | 2.10 | Regular point |
| 3 | 3.00 | 2.90 | Regular point |
| 4 | 4.00 | 4.20 | Regular point |
| 5 | 5.00 | 5.10 | Regular point |
| 6 | 8.00 | 20.50 | High outlier |
| 7 | 10.00 | 10.10 | Regular point |
| 8 | 12.00 | 3.80 | Low outlier |
This example includes two unusual observations so you can see how robust weighting changes the fitted line compared with ordinary least squares.
Formula used
1) Initial line
Start with an ordinary least squares estimate: ŷ = a + bx.
2) Residuals
For each point, compute the residual: rᵢ = yᵢ − (a + bxᵢ).
3) Robust scale
Estimate spread with MAD: s = median(|rᵢ − median(r)|) / 0.6745.
4) Standardized residuals
Convert residuals into scaled form: uᵢ = (rᵢ − median(r)) / (c × s), where c is the tuning constant.
5) Weight functions
Huber: wᵢ = 1 when |uᵢ| ≤ 1, otherwise 1 / |uᵢ|.
Tukey bisquare: wᵢ = (1 − uᵢ²)² when |uᵢ| < 1, otherwise 0.
Cauchy: wᵢ = 1 / (1 + uᵢ²).
6) Weighted update
Refit the line using weighted least squares, then iterate until the coefficient change becomes smaller than the chosen tolerance.
7) Diagnostics
The calculator reports coefficients, predicted values, residuals, pseudo R², RMSE, weighted RMSE, MAD scale, and point weights.
How to use this calculator
- Paste paired observations as one x,y pair per line.
- Choose Huber, Tukey bisquare, or Cauchy weighting.
- Set the tuning constant, iteration limit, and convergence tolerance.
- Enter an x value if you want a fitted prediction.
- Press the submit button to calculate the robust line.
- Read the result cards above the form under the header.
- Compare robust and ordinary regression in the summary table.
- Export diagnostics as CSV or PDF for reporting.
FAQs
1) What makes robust regression different from ordinary regression?
Ordinary regression gives every point equal influence. Robust regression reduces the leverage of unusual observations, so the fitted line stays closer to the main pattern in noisy data.
2) What do the final weights mean?
Weights show how strongly each observation affects the final fit. Values near one keep strong influence, while small weights indicate observations treated as unusual or less trustworthy.
3) Why does the calculator show both robust and ordinary fits?
The comparison helps you see whether outliers materially changed the slope, intercept, and error metrics. Large differences usually signal that robust fitting is adding useful protection.
4) How should I choose the tuning constant?
Use standard defaults first. Smaller values make the model more resistant to outliers, while larger values behave more like ordinary regression and downweight fewer points.
5) Does robust regression delete outliers?
No. It usually keeps all points but changes their influence through weights. Some methods, such as Tukey bisquare, may assign very small or zero weight to severe outliers.
6) What minimum data size is recommended?
Three points are the minimum for this calculator, but more observations are better. Robust methods are most helpful when you have enough data to separate the main trend from unusual values.
7) Can I use this for strongly curved relationships?
Not directly. This tool fits a straight line. If the true pattern is curved, transform the variables or use a nonlinear or polynomial robust model instead.
8) When should I prefer Tukey, Huber, or Cauchy?
Huber is a balanced general choice. Tukey is stronger against large outliers. Cauchy offers smoother downweighting and can work well when you expect several moderate deviations.