How Loess Works
How Loess Works
Loess (or lowess, Locally Weighted Scatterplot Smoothing) is a scatterplot smoother, which provides a flexible method for nonparametric regression.
Elements in the graphic:
• blue points: data points under the smoother
• black points: data points not under the smoother
• black curve: the loess smoother
• dark red dot: the loess fit at the current position
• dark red line or curve: the loess curve with parameters fixed at those corresponding to the red dot
• purple bars: window shape and the corresponding loess weights, with scale indicated on the right axis
Controls:
• , the position at which the point on the loess curve is calculated. As you slide , notice how the window width changes. The number of points in the window, whose positions are indicated by the green bars, remains constant.
x
0
x
0
• , the fraction of data under the smoother. As increases, the window width increases and more smoothing is done.
α
α
λ=0,1,or2
Details
Details
Given bivariate observations , , the basic model that can be fitted may be written as
(,)
x
i
y
i
i=1,2,…,n
y
i
x
i
ϵ
i
i=1,…,n
where ~NID(0,) and is a local polynomial of degree , which may be written as
e
i
2
σ
g(x)
λ≥0
g(x)=+x+…+
(x)
β
0
(x)
β
1
(x)
β
λ
λ
x
The parameters ,,…, are estimated by weighted least squares for each value of . The weight function weights the data, , so that data values near to have greater weight than those farther away from . Following[1], we use the tricube weight function,
(x)
β
0
(x)
β
1
(x)
β
λ
x
(,)
x
i
y
i
x
x
T(z)=
3 1-z 3 | | |z|≤1, |
0 | |z|>1, |
with (x)=T((x)/Δ(x,α)) to define the local neighborhood weights for the data at the point .
w
i
Δ
i
x
Here (x)=|x-| and controls the amount of smoothing (larger values of result in more smoothing). As , (x)1 for each , and the local linear model reduces to the standard parametric polynomial regression. For , is the distance to the nearest neighbor, where ( is the integer part function). Hence, , where (x) denotes the largest value of (x), . For , . It follows that as , the local linear model reduces to a parametric polynomial regression of degree .
Δ
i
x
i
Δ(x,α)
Δ(x,α)
Δ(x,α)∞
w
i
i=1,2,…,n
0<α≤1
Δ(x,α)
th
q
q=[αn]
[·]
Δ(x,α)=(x)
Δ
(q)
Δ
(q)
th
q
Δ
i
i=1,…,n
α>1
Δ(x,α)=α(x)
Δ
(n)
α∞
λ
In practice we work with local constant loess, ; local linear, , or local quadratic, .
λ=0
λ=1
λ=2
[1] W. S. Cleveland, Visualizing Data, New Jersey: Summit, 1993.
External Links
External Links
Permanent Citation
Permanent Citation
Ian McLeod
"How Loess Works"
http://demonstrations.wolfram.com/HowLoessWorks/
Wolfram Demonstrations Project
Published: March 29, 2011