WOLFRAM NOTEBOOK

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:
x
0
, the position at which the point on the loess curve is calculated. As you slide
x
0
, notice how the window width changes. The number of points in the window, whose positions are indicated by the green bars, remains constant.
α
, the fraction of data under the smoother. As
α
increases, the window width increases and more smoothing is done.
λ=0,1,or2
indicates the degree of the local polynomial.

Details

Given bivariate observations
(
x
i
,
y
i
)
,
i=1,2,,n
, the basic model that can be fitted may be written as
y
i
=g(
x
i
)+
ϵ
i
,
i=1,,n
,
where
e
i
~NID(0,
2
σ
)
and
g(x)
is a local polynomial of degree
λ0
, which may be written as
g(x)=
(x)
β
0
+
(x)
β
1
x++
(x)
β
λ
λ
x
.
The parameters
(x)
β
0
,
(x)
β
1
,,
(x)
β
λ
are estimated by weighted least squares for each value of
x
. The weight function weights the data,
(
x
i
,
y
i
)
, so that data values near to
x
have greater weight than those farther away from
x
. Following[1], we use the tricube weight function,
T(z)=
3
1-z
3
|
|z|1,
0
|z|>1,
with
w
i
(x)=T(
Δ
i
(x)/Δ(x,α))
to define the local neighborhood weights for the data at the point
x
.
Here
Δ
i
(x)=|x-
x
i
|
and
Δ(x,α)
controls the amount of smoothing (larger values of
Δ(x,α)
result in more smoothing). As
Δ(x,α)
,
w
i
(x)1
for each
i=1,2,,n
, and the local linear model reduces to the standard parametric polynomial regression. For
0<α1
,
Δ(x,α)
is the distance to the
th
q
nearest neighbor, where
q=[αn]
(
[·]
is the integer part function). Hence,
Δ(x,α)=
Δ
(q)
(x)
, where
Δ
(q)
(x)
denotes the
th
q
largest value of
Δ
i
(x)
,
i=1,,n
. For
α>1
,
Δ(x,α)=α
Δ
(n)
(x)
. It follows that as
α
, the local linear model reduces to a parametric polynomial regression of degree
λ
.
In practice we work with local constant loess,
λ=0
; local linear,
λ=1
, or local quadratic,
λ=2
.
[1] W. S. Cleveland, Visualizing Data, New Jersey: Summit, 1993.

External Links

Permanent Citation

Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.