Robustness

Outlier handling through iterative reweighting.

How Robustness Works

Standard LOWESS can be biased by outliers. Robustness iterations downweight points with large residuals:

  1. Fit initial LOWESS
  2. Compute residuals
  3. Assign robustness weights (large residuals → low weight)
  4. Refit using combined distance × robustness weights
  5. Repeat steps 2–4

Robustness Methods

Robustness Iterations


Robustness Methods

Bisquare (Default)

Smooth downweighting. Points transition gradually from full weight to zero.

\[w(u) = \begin{cases} (1 - u^2)^2 & |u| < 1 \\ 0 & |u| \geq 1 \end{cases}\]

Use when: General purpose, balanced approach.

using FastLOWESS
using Random, Statistics

rng = MersenneTwister(42)
x = collect(range(0, 2π, length=100))
y = sin.(x) .+ randn(rng, 100) .* 0.3

model = Lowess(; iterations=3, robustness_method="bisquare")
result = fit(model, x, y)
println("First smoothed value (bisquare robustness): ", result.y[1])
First smoothed value (bisquare robustness): 0.4426033958974517

Huber

Linear penalty beyond threshold. Less aggressive than Bisquare.

\[w(u) = \begin{cases} 1 & |u| \leq k \\ k/|u| & |u| > k \end{cases}\]

Use when: Moderate outliers, want to retain some influence.

using FastLOWESS
using Random, Statistics

rng = MersenneTwister(42)
x = collect(range(0, 2π, length=100))
y = sin.(x) .+ randn(rng, 100) .* 0.3

model = Lowess(; iterations=3, robustness_method="huber")
result = fit(model, x, y)
println("First smoothed value (huber robustness): ", result.y[1])
First smoothed value (huber robustness): 0.43650732026121564

Talwar

Hard threshold. Points are either fully weighted or completely excluded.

\[w(u) = \begin{cases} 1 & |u| \leq k \\ 0 & |u| > k \end{cases}\]

Use when: Extreme outliers, want binary exclusion.

using FastLOWESS
using Random, Statistics

rng = MersenneTwister(42)
x = collect(range(0, 2π, length=100))
y = sin.(x) .+ randn(rng, 100) .* 0.3

model = Lowess(; iterations=3, robustness_method="talwar")
result = fit(model, x, y)
println("First smoothed value (talwar robustness): ", result.y[1])
First smoothed value (talwar robustness): 0.42875740979660093

Comparison

MethodTransitionAggressivenessUse Case
BisquareSmoothModerateGeneral purpose
HuberGradualMildPreserve influence
TalwarHardStrongExtreme contamination

Detecting Outliers

Use robustness weights to identify potential outliers:

using FastLOWESS
using Random, Statistics

rng = MersenneTwister(42)
x = collect(range(0, 2π, length=100))
y = sin.(x) .+ randn(rng, 100) .* 0.3

model = Lowess(; iterations=5, outputs=["weights"])
result = fit(model, x, y)

shown = 0
for (i, w) in enumerate(result.robustness_weights)
    global shown
    if w < 0.5 && shown < 5
        println("Potential outlier at index $i: weight = $w")
        shown += 1
    end
end
Potential outlier at index 24: weight = 0.44572699983981534
Potential outlier at index 29: weight = 0.3857475192389485
Potential outlier at index 41: weight = 0.3814691920789072
Potential outlier at index 68: weight = 0.08122538921499627

Scale Estimation

Residuals are scaled before computing robustness weights. Two methods:

MethodFormulaRobustness
MADmedian(|r − median(r)|)Very robust (default)
MARmedian(|r|)Robust, uncentered
Meanmean(|r|)Less robust, fastest

Scaling Methods Comparison

using FastLOWESS
using Random, Statistics

rng = MersenneTwister(42)
x = collect(range(0, 2π, length=100))
y = sin.(x) .+ randn(rng, 100) .* 0.3

model = Lowess(; iterations=3, scaling_method="mad")
result = fit(model, x, y)
println("First smoothed value (MAD scaling): ", result.y[1])
First smoothed value (MAD scaling): 0.4426033958974517

Auto-Convergence

Stop iterations early when weights stabilize:

Performance

Auto-convergence can significantly reduce computation when weights stabilize before reaching max iterations.

using FastLOWESS
using Random, Statistics

rng = MersenneTwister(42)
x = collect(range(0, 2π, length=100))
y = sin.(x) .+ randn(rng, 100) .* 0.3

model = Lowess(; iterations=10, auto_converge=1e-6)
result = fit(model, x, y)
println("First smoothed value (auto_converge enabled): ", result.y[1])
First smoothed value (auto_converge enabled): 0.44247237863556826