Algorithm Search⌘K

Algorithmadvanced

Least trimmed squares

Also called LTS regression, FAST-LTS.

Regression that minimizes the sum of the h smallest squared residuals. FAST-LTS finds it by random starts and concentration steps that never increase the objective.

Time
O(S c (n p^2 + p^3 + n log n)) worst
Space
O(n p + p^2) extra
Where
S = the number of random starts; c = the number of C-steps for each start; n = the number of rows; p = the number of coefficients
Properties
randomizednot exactnot in placeofflinerandomizedregression equivariant
Origin
Peter J. Rousseeuw, Katrien Van Driessen, Annick M. Leroy, Jan Ámos Víšek, 1984

Least trimmed squares (LTS) fits a regression by least squares on the best part of the data. For a coverage hh, usually a little more than n/2n/2, it chooses the coefficients that make the sum of the hh smallest squared residuals as small as possible. The other n−hn - h points, the worst fitted ones, do not count at all. So LTS has a breakdown point near 1/2, like least median of squares, but it converges at the usual rate n−1/2n^{-1/2}. The exact fit needs a search over subsets. FAST-LTS finds a good one by random starts and concentration steps (C-steps): each C-step refits least squares on the hh best fitted points, and it never makes the objective larger.

In plain words

Pick a line, any line. Look at the points closest to it, just over half of them, and fit ordinary least squares to those points only. The new line fits those points at least as well as the old one, so the total squared error of its closest half can only go down. Repeat until the chosen points stop changing.

This walk downhill can stop at the wrong place: if it starts on a line through bad points, it may settle on a fit of the bad points. So we start many times, from lines through a few random points, and keep the best result. If more than half of the points are good, some starts will use only good points, and those lead to a good fit.

The problem

The input is a design XX with rows x1,…,xn∈Rpx_1, \ldots, x_n \in \mathbb{R}^p and responses yy, in the notation y=Xb+ey = X b + e, and a coverage hh with n/2<h≤nn/2 < h \le n. For coefficients bb, let ri(b)=yi−xi⊤br_i(b) = y_i - x_i^\top b, and let r(1)2(b)≤⋯≤r(n)2(b)r^2_{(1)}(b) \le \cdots \le r^2_{(n)}(b) be the squared residuals in order. The LTS fit minimizes

Q(b)=∑k=1hr(k)2(b).Q(b) = \sum_{k=1}^{h} r^2_{(k)}(b).

The usual choice is h=⌊(n+p+1)/2⌋h = \lfloor (n + p + 1)/2 \rfloor, which gives the highest breakdown point. A larger hh, such as 0.75n0.75 n, gives more efficiency and a lower breakdown point. With h=nh = n, LTS is ordinary least squares.

The algorithm

Equivalently, LTS looks for the subset HH of hh rows whose least squares fit has the smallest residual sum of squares. FAST-LTS searches this space with C-steps. This is the core of the method; the full FAST-LTS adds the refinements listed under the variants.

  1. FAST-LTS(X, y, h, S)
  2. 1for each of S random starts do
  3. 2b ← the exact fit through p random rows ▷ draw again if they are singular
  4. 3repeat
  5. 4b' ← C-STEP(b)
  6. 5if Q(b') ≥ Q(b) then leave the repeat loop; b ← b'
  7. 6if Q(b) is the smallest so far then b* ← b
  8. 7return b* and Q(b*)
  9. C-STEP(b) ▷ concentration step
  10. 8H ← the h rows with the smallest r_i(b)²
  11. 9return the least squares fit on the rows of H

The C-step works because of one chain of inequalities. Let HH be the hh rows best fitted by bb, and b′b' the least squares fit on HH. The hh smallest squared residuals of b′b' sum to at most its sum over HH; that is at most the sum of bb over HH, because b′b' is the least squares fit there; and that is Q(b)Q(b):

Q(b′)≤RSSH(b′)≤RSSH(b)=Q(b).Q(b') \le \mathrm{RSS}_H(b') \le \mathrm{RSS}_H(b) = Q(b).

Example

Ten points; the first seven lie near the line y=1+2xy = 1 + 2x, and the last three are bad.

ii 1 2 3 4 5 6 7 8 9 10
xix_i 1 2 3 4 5 6 7 8 9 10
yiy_i 3 5 8 9 11 14 15 2 1 0

Here p=2p = 2 (intercept and slope) and h=⌊13/2⌋=6h = \lfloor 13/2 \rfloor = 6. Least squares on all ten points gives y=8.93−0.388 xy = 8.93 - 0.388\,x, with the wrong sign of the slope. The exact LTS fit, found by trying all (106)=210\binom{10}{6} = 210 subsets, uses the points {1,2,4,5,6,7}\{1, 2, 4, 5, 6, 7\}:

y=142161+333161x≈0.882+2.068 x,Q=114161≈0.708.y = \tfrac{142}{161} + \tfrac{333}{161} x \approx 0.882 + 2.068\,x, \qquad Q = \tfrac{114}{161} \approx 0.708.

C-steps from three starts give:

start (line L2) QQ at start subset of the C-step fit after it QQ after it next C-step
points 1, 2: y=1+2xy = 1 + 2x 1 {1, 2, 3, 4, 5, 7} 1.271+1.971x1.271 + 1.971x 57/70 ≈ 0.814 no change
points 8, 9: y=10−xy = 10 - x 19 {2, 3, 4, 8, 9, 10} 9.856−0.948x9.856 - 0.948x 1625/87 ≈ 18.68 no change
points 2, 9: y=6.14−0.571xy = 6.14 - 0.571x 19.73 {1, 2, 3, 8, 9, 10} 6.183−0.548x6.183 - 0.548x 1816/93 ≈ 19.53 no change

The objective drops at every step, as the C-step theorem says, but each run stops at a fixed point. The first start reaches a good fit with Q=0.814Q = 0.814, close to the best value 0.708 but not equal to it: the line 1+2x1 + 2x fits points 3 and 6 equally badly, and the tie is broken toward point 3. The other two starts stop at fits of the bad points. On these data none of the 45 starts from a pair of points reaches the global minimum; the test file checks this. FAST-LTS with 50 starts returns Q=57/70Q = 57/70, a good fit but an upper bound on the minimum. In the test file, on 30 random data sets with nn from 6 to 12 and a third of the points bad, 20 starts reached the exact minimum every time. These are measurements on small data, not a guarantee.

Correctness

For any bb, the sum of the hh smallest squared residuals is the least residual sum over sets of hh rows. So the minimum of QQ is the minimum over hh-subsets of the least squares residual sum on the subset, and the exact LTS fit is least squares on the best subset. The C-step never increases QQ, by the chain above, and while it decreases QQ strictly it cannot use the same subset twice, so each run stops after at most (nh)\binom nh steps, and in practice after a few. The global minimizer is a fixed point of the C-step, but other fixed points exist, so FAST-LTS returns an upper bound on the minimum, which is exact when a start falls in the basin of the global minimum. The full proofs are below.

Proof: LTS is least squares on the best h-subset, and the C-step never increases the trimmed objectivefull

Setting. The data are rows x1,…,xn∈Rpx_1, \ldots, x_n \in \mathbb{R}^p of the design XX and responses y1,…,yny_1, \ldots, y_n, in the notation y=Xb+ey = X b + e. For a coefficient vector bb, ri(b)=yi−xi⊤br_i(b) = y_i - x_i^\top b, and the squared residuals sorted are r(1)2(b)≤⋯≤r(n)2(b)r^2_{(1)}(b) \le \cdots \le r^2_{(n)}(b). For 1≤h≤n1 \le h \le n the LTS objective is

Q(b)=∑k=1hr(k)2(b),Q(b) = \sum_{k=1}^{h} r^2_{(k)}(b),

and for a set HH of rows, RSSH(b)=∑i∈Hri(b)2\mathrm{RSS}_H(b) = \sum_{i \in H} r_i(b)^2.

Part 1. LTS as a search over subsets

Lemma 1. For every bb, Q(b)=min⁡∣H∣=hRSSH(b)Q(b) = \min_{|H| = h} \mathrm{RSS}_H(b), and the minimum is attained by the hh rows with the smallest squared residuals.

Proof. Any hh of the numbers ri(b)2r_i(b)^2 sum to at least the sum of the hh smallest, and the hh smallest attain it. □\square

Theorem 2. min⁡bQ(b)=min⁡∣H∣=hmin⁡bRSSH(b)\min_b Q(b) = \min_{|H| = h} \min_b \mathrm{RSS}_H(b). If H∗H^* attains the outer minimum, the least squares fit on H∗H^* is an LTS fit.

Proof. By Lemma 1, min⁡bQ(b)=min⁡bmin⁡HRSSH(b)\min_b Q(b) = \min_b \min_H \mathrm{RSS}_H(b), and two minima can be swapped. For a fixed HH, the inner minimum over bb is the least squares fit on the rows of HH. If b∗b^* is that fit for H∗H^*, then Q(b∗)≤RSSH∗(b∗)=min⁡bQ(b)Q(b^*) \le \mathrm{RSS}_{H^*}(b^*) = \min_b Q(b). □\square

So the enumeration over all (nh)\binom nh subsets in the test file returns the exact LTS fit, when every subset has a full-rank design. When a subset is rank deficient, its least squares fit is not unique, but its minimum value is still well defined; the code skips such subsets, which is safe when the data have distinct design rows in the needed sense, as in the tests.

Part 2. The concentration step

The C-step of lines L8 and L9 takes bb, lets HH be the hh rows with the smallest ri(b)2r_i(b)^2, and returns the least squares fit b′b' on HH.

Theorem 3 (Rousseeuw and Van Driessen). Q(b′)≤Q(b)Q(b') \le Q(b), with equality only if bb is itself a least squares fit on HH (when the fit on HH is unique, only if b′=bb' = b).

Proof. By Lemma 1, Q(b′)≤RSSH(b′)Q(b') \le \mathrm{RSS}_H(b'). Since b′b' minimizes RSSH\mathrm{RSS}_H, RSSH(b′)≤RSSH(b)\mathrm{RSS}_H(b') \le \mathrm{RSS}_H(b). And RSSH(b)=Q(b)\mathrm{RSS}_H(b) = Q(b) by the choice of HH. So

Q(b′)≤RSSH(b′)≤RSSH(b)=Q(b).Q(b') \le \mathrm{RSS}_H(b') \le \mathrm{RSS}_H(b) = Q(b).

If Q(b′)=Q(b)Q(b') = Q(b), the middle inequality is an equality, so bb also minimizes RSSH\mathrm{RSS}_H. □\square

Corollary 4 (termination). The loop of lines L3 to L5 stops after at most (nh)\binom nh C-steps.

Proof. Let b1,b2,…b_1, b_2, \ldots be the fits made by the C-steps, and H1,H2,…H_1, H_2, \ldots the subsets they were fitted on. Line L9 computes the fit from the subset alone, so Hi=HjH_i = H_j gives bi=bjb_i = b_j. While the loop runs, Q(b1)>Q(b2)>⋯Q(b_1) > Q(b_2) > \cdots strictly, so the fits are all different, and so are the subsets. There are (nh)\binom nh subsets. □\square

In practice the loop stops after a few steps. When it stops, bb is a fixed point in value: the hh rows it fits best are a subset on which it is a least squares fit. Theorem 2 shows that the global minimizer is such a fixed point, but there can be other fixed points. The example on the page has one, which is why FAST-LTS uses many random starts and returns the best of them. FAST-LTS is therefore a heuristic: the value it returns is an upper bound on min⁡bQ\min_b Q, and it is exact when one of its starts lies in the basin of the global minimum.

Part 3. Cost

A C-step computes nn residuals in O(np)O(np) time, selects the hh smallest in O(n)O(n) expected time (or O(nlog⁡n)O(n \log n) by sorting, as in the code), and solves the normal equations in O(np2+p3)O(np^2 + p^3) time. With SS starts and at most cc steps each, FAST-LTS takes O(Sc(np2+p3+nlog⁡n))O(S c (n p^2 + p^3 + n \log n)) time.

What is cited, not proved

The breakdown point (n−h+1)/n(n - h + 1)/n for data in general position, which is (⌊(n−p)/2⌋+1)/n(\lfloor (n - p)/2 \rfloor + 1)/n for h=⌊(n+p+1)/2⌋h = \lfloor (n + p + 1)/2 \rfloor (Rousseeuw and Leroy 1987), and the n\sqrt n rate with asymptotic normality (Víšek 2006) are cited on the page. They are not proved here.

Complexity

  • One C-step costs O(np)O(np) for the residuals, O(n)O(n) expected for selecting the hh smallest (or O(nlog⁡n)O(n \log n) by sorting), and O(np2+p3)O(np^2 + p^3) for least squares. Usually cc, the number of steps until a fixed point, is small.
  • FAST-LTS with SS starts takes O(Sc(np2+p3+nlog⁡n))O(S c (np^2 + p^3 + n \log n)) time and O(np+p2)O(np + p^2) extra space. Rousseeuw and Van Driessen use S=500S = 500 starts, two C-steps for each, and full iteration only for the 10 best.
  • Exact LTS by enumeration of hh-subsets takes (nh)\binom nh least squares fits, practical only for nn up to about 20. Exact methods with branch and bound reach a little further. No exact algorithm is known whose time is polynomial in both nn and pp.
  • How many starts. A start uses only good rows with probability (1−ε)p(1 - \varepsilon)^p when a fraction ε\varepsilon is bad, so about log⁡α/log⁡(1−(1−ε)p)\log \alpha / \log(1 - (1 - \varepsilon)^p) starts give a clean one with probability 1−α1 - \alpha; see the RANSAC iteration bound. A clean start usually, but not always, leads to the global minimum, as the example shows.

Properties

  • Breakdown point. For data in general position, (n−h+1)/n(n - h + 1)/n, which is (⌊(n−p)/2⌋+1)/n(\lfloor (n - p)/2 \rfloor + 1)/n for h=⌊(n+p+1)/2⌋h = \lfloor (n + p + 1)/2 \rfloor, the highest possible for a regression equivariant estimator (Rousseeuw and Leroy 1987). This is cited, not proved here.
  • Root-n rate. LTS is n\sqrt n-consistent and asymptotically normal under regularity conditions (Víšek 2006). Its efficiency at the normal model is low for h≈n/2h \approx n/2, about 7 percent (Rousseeuw and Leroy 1987), and grows with hh. This is cited, not proved here.
  • Exact fit. If at least hh points lie exactly on one hyperplane, Q=0Q = 0 there, and that hyperplane is an LTS fit. The test file checks this with 6 of 10 points on a line.
  • Equivariance. Regression, scale and affine equivariant, like least squares.
  • Monotone search. Every C-step gives a fit at least as good as before. This makes FAST-LTS simple to check and to stop.

Variants and improvements

  • Full FAST-LTS. Rousseeuw and Van Driessen (2006) add three refinements: two C-steps only from each start, then full iteration from the 10 best (selective iteration); for large nn, a run on disjoint subsamples of about 300 rows and then on their union (nested extensions); and an intercept adjustment for each candidate.
  • Reweighted LTS. After LTS, estimate a robust scale from the hh residuals, give weight 0 to points with a standardized residual above about 2.5, and fit least squares to the rest. This raises the efficiency and keeps the breakdown point.
  • The same idea for covariance. FAST-MCD uses the same C-step for the minimum covariance determinant: refit the mean and covariance on the hh points with the smallest Mahalanobis distances. The determinant never increases.
  • Trimmed problems elsewhere. The trimmed mean is LTS for location, where the exact solution is a window of hh consecutive order statistics. Trimmed ICP uses the same trimming for point cloud alignment.
  • MM-estimators. LTS is a common starting fit for an MM-estimator, which then reaches high efficiency.

When to use it

Use LTS when you need a regression that resists up to almost half bad rows, including bad leverage points, in more than one predictor. It is the standard high breakdown fit in robust statistics software, and it is the basis of robust outlier diagnostics: plot the standardized LTS residuals against robust distances of the rows. Prefer it to LMS, which converges more slowly. If the fraction of bad rows is small and leverage is not a concern, an M-estimator or iteratively reweighted least squares is cheaper.

Pitfalls

  • Treating the FAST-LTS result as exact. It is the best fixed point found, an upper bound on the minimum. The example shows a clean start that misses the global minimum. Use more starts when the answer matters, and check whether different seeds agree.
  • Coverage h too small or too large. With hh near n/2n/2 the efficiency is low; with hh near nn the breakdown point is low. h=0.75nh = 0.75n is a common compromise.
  • Singular subsets. With categorical or discrete predictors, many pp-subsets are singular. Draw again, or add rows until the subset has full rank.
  • Ties in residuals. When two rows have equal residuals at the hh-th place, the choice changes the next fit. Results can depend on the tie rule.
  • Inference. Standard errors from least squares on the chosen subset ignore the selection; use the reweighted fit or the bootstrap.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

least_trimmed_squares.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/least-trimmed-squares/. The authors are listed in prov/DQP8F6.jsonl.

import random
from fractions import Fraction
from itertools import combinations


def default_h(n, p):
    """h = floor((n + p + 1) / 2), the coverage with the best breakdown point."""
    return (n + p + 1) // 2


def solve(A, b):
    """Solve A z = b exactly by Gaussian elimination; None if A is singular."""
    m = len(A)
    M = [list(map(Fraction, row)) + [Fraction(v)] for row, v in zip(A, b)]
    for c in range(m):
        piv = next((r for r in range(c, m) if M[r][c] != 0), None)
        if piv is None:
            return None
        M[c], M[piv] = M[piv], M[c]
        for r in range(m):
            if r != c and M[r][c] != 0:
                f = M[r][c] / M[c][c]
                M[r] = [u - f * v for u, v in zip(M[r], M[c])]
    return [M[i][m] / M[i][i] for i in range(m)]


def ols(X, y, idx):
    """Least squares coefficients on the rows idx, by the normal equations."""
    p = len(X[0])
    A = [[sum(X[i][a] * X[i][c] for i in idx) for c in range(p)] for a in range(p)]
    rhs = [sum(X[i][a] * y[i] for i in idx) for a in range(p)]
    return solve(A, rhs)


def residuals2(X, y, b):
    return [(y[i] - sum(u * v for u, v in zip(X[i], b))) ** 2 for i in range(len(y))]


def objective(X, y, b, h):
    """Sum of the h smallest squared residuals."""
    return sum(sorted(residuals2(X, y, b))[:h])


def c_step(X, y, b, h):
    """One concentration step: refit least squares on the h points with the
    smallest squared residuals. The objective never increases."""
    r = residuals2(X, y, b)
    H = sorted(range(len(y)), key=lambda i: r[i])[:h]  # @line L8
    b_new = ols(X, y, H)  # @line L9
    return b if b_new is None else b_new


def fast_lts(X, y, h=None, starts=50, rng=None, max_steps=100):
    """FAST-LTS core: random p-subsets, then C-steps until the objective stops
    falling; keep the best. Returns (coefficients, objective)."""
    rng = rng or random.Random(0)
    X = [[Fraction(v) for v in row] for row in X]
    y = [Fraction(v) for v in y]
    n, p = len(X), len(X[0])
    h = h or default_h(n, p)
    best = None
    for _ in range(starts):  # @line L1
        b = ols(X, y, rng.sample(range(n), p))  # @line L2
        if b is None:
            continue
        q = objective(X, y, b, h)
        for _ in range(max_steps):  # @line L3
            b2 = c_step(X, y, b, h)  # @line L4
            q2 = objective(X, y, b2, h)
            if q2 >= q:  # @line L5
                break
            b, q = b2, q2
        if best is None or q < best[1]:  # @line L6
            best = (b, q)
    if best is None:
        raise ValueError("every random subset was singular")
    return best  # @line L7


def lts_exact(X, y, h=None):
    """Exact LTS by trying every h-subset (small n only). Returns
    (coefficients, objective)."""
    X = [[Fraction(v) for v in row] for row in X]
    y = [Fraction(v) for v in y]
    n, p = len(X), len(X[0])
    h = h or default_h(n, p)
    best = None
    for H in combinations(range(n), h):
        b = ols(X, y, H)
        if b is None:
            continue
        q = sum(residuals2([X[i] for i in H], [y[i] for i in H], b))
        if best is None or q < best[1]:
            best = (b, q)
    return best


def design(x):
    """Rows [1, x_i] for simple regression."""
    return [[1, v] for v in x]
test_least_trimmed_squares.py 120 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/least-trimmed-squares/. The authors are listed in prov/DQP8F6.jsonl.

import random
from fractions import Fraction
from itertools import combinations

from least_trimmed_squares import (
    c_step, default_h, design, fast_lts, lts_exact, objective, ols,
)

PAGE_X = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
PAGE_Y = [3, 5, 8, 9, 11, 14, 15, 2, 1, 0]


def F(rows):
    return [[Fraction(v) for v in r] for r in rows]


def test_page_example() -> None:
    X, y = F(design(PAGE_X)), [Fraction(v) for v in PAGE_Y]
    h = default_h(10, 2)
    assert h == 6
    b, q = lts_exact(X, y)
    assert b == [Fraction(142, 161), Fraction(333, 161)]
    assert q == Fraction(114, 161)
    # C-steps from the pair {1, 2} stop at a local minimum.
    b = ols(X, y, [0, 1])
    assert b == [1, 2] and objective(X, y, b, h) == 1
    b = c_step(X, y, b, h)
    assert b == [Fraction(89, 70), Fraction(69, 35)]
    assert objective(X, y, b, h) == Fraction(57, 70)
    assert c_step(X, y, b, h) == b
    # From the bad pair {8, 9} they stop at a fit of the bad points.
    b = ols(X, y, [7, 8])
    assert b == [10, -1] and objective(X, y, b, h) == 19
    b = c_step(X, y, b, h)
    assert objective(X, y, b, h) == Fraction(1625, 87)
    assert c_step(X, y, b, h) == b
    # No start from a pair reaches the global minimum on these data.
    for P in combinations(range(10), 2):
        b = ols(X, y, list(P))
        q = objective(X, y, b, h)
        while True:
            b2 = c_step(X, y, b, h)
            q2 = objective(X, y, b2, h)
            if q2 >= q:
                break
            b, q = b2, q2
        assert q > Fraction(114, 161)
    # So FAST-LTS returns the good local minimum, an upper bound.
    assert fast_lts(design(PAGE_X), PAGE_Y, starts=50)[1] == Fraction(57, 70)


def test_c_step_never_increases() -> None:
    rng = random.Random(41)
    for _ in range(300):
        n = rng.randint(3, 12)
        X = F(design(rng.sample(range(-20, 20), n)))
        y = [Fraction(rng.randint(-20, 20)) for _ in range(n)]
        h = rng.randint(2, n)
        b = [Fraction(rng.randint(-9, 9), rng.randint(1, 3)) for _ in range(2)]
        assert objective(X, y, c_step(X, y, b, h), h) <= objective(X, y, b, h)


def test_exact_is_the_minimum() -> None:
    rng = random.Random(42)
    for _ in range(40):
        n = rng.randint(4, 10)
        X = F(design(rng.sample(range(-10, 10), n)))
        y = [Fraction(rng.randint(-10, 10)) for _ in range(n)]
        h = default_h(n, 2)
        b, q = lts_exact(X, y)
        assert objective(X, y, b, h) == q
        # No line on a grid, and no fixed point of the C-steps, does better.
        for _ in range(100):
            g = [Fraction(rng.randint(-40, 40), 4), Fraction(rng.randint(-20, 20), 4)]
            assert objective(X, y, g, h) >= q
        # The optimum is a fixed point in value.
        assert objective(X, y, c_step(X, y, b, h), h) == q


def test_fast_lts_against_enumeration() -> None:
    rng = random.Random(43)
    hits = 0
    trials = 30
    for t in range(trials):
        n = rng.randint(6, 12)
        x = rng.sample(range(0, 30), n)
        y = [2 * v + 1 + rng.randint(-2, 2) for v in x]
        for i in rng.sample(range(n), (n - 1) // 3):
            y[i] = rng.randint(-60, 60)
        exact = lts_exact(design(x), y)[1]
        got = fast_lts(design(x), y, starts=20, rng=random.Random(t))[1]
        assert got >= exact
        hits += got == exact
    assert hits >= trials // 2


def test_quadratic_model() -> None:
    rng = random.Random(44)
    for _ in range(10):
        n = rng.randint(6, 9)
        x = rng.sample(range(-6, 7), n)
        X = [[1, v, v * v] for v in x]
        y = [v * v - 2 * v + 3 for v in x]
        y[0] += 50
        b, q = lts_exact(X, y)
        assert q == 0 and b == [3, -2, 1]
        b2, q2 = fast_lts(X, y, starts=40, rng=random.Random(n))
        assert q2 == 0 and b2 == [3, -2, 1]


def test_exact_fit_with_majority_on_a_line() -> None:
    x = list(range(10))
    y = [3 - 2 * v for v in x]
    for i, v in zip((1, 4, 6, 9), (100, -50, 77, 0)):
        y[i] = v
    b, q = fast_lts(design(x), y, starts=30)
    assert q == 0 and b == [3, -2]

History

Rousseeuw proposed least trimmed squares in his 1984 paper on least median of squares, and the book of Rousseeuw and Leroy (1987) studied both. LMS was used more at first, because it was easier to approximate. That changed when Rousseeuw and Van Driessen found the C-step theorem: first for the minimum covariance determinant (FAST-MCD, 1999), then for regression in FAST-LTS, published in 2006. Víšek proved the asymptotic normality of LTS in a series of papers that ended in 2006.

References

  1. Peter J. Rousseeuw, Least median of squares regression, Journal of the American Statistical Association 79(388), 1984, pp. 871 to 880 (least trimmed squares is proposed there next to LMS)
  2. Peter J. Rousseeuw and Annick M. Leroy, Robust Regression and Outlier Detection, Wiley, 1987, Chapter 3 (the breakdown point of LTS for the coverage h, and its asymptotic efficiency) and Chapter 4 (properties of LTS)
  3. Peter J. Rousseeuw and Katrien Van Driessen, Computing LTS regression for large data sets, Data Mining and Knowledge Discovery 12(1), 2006, pp. 29 to 45 (the C-step theorem, the FAST-LTS algorithm with random p-subsets, selective iteration and nested extensions)
  4. Jan Ámos Víšek, The least trimmed squares. Part III: Asymptotic normality, Kybernetika 42(2), 2006, pp. 203 to 224, The whole paper (root-n consistency and asymptotic normality of LTS)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example