Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2011 Dan Nettleton

Similar presentations


Presentation on theme: "Copyright © 2011 Dan Nettleton"— Presentation transcript:

1 Copyright © 2011 Dan Nettleton
The LOWESS Smoother 1/19/2011 Copyright © 2011 Dan Nettleton 1

2 LOWESS “lowess” stands for LOcally WEighted polynomial regreSSion.
The original reference for lowess is Cleveland, W. S. (1979). Robust locally weighted regression and smoothing scatterplots. JASA 2

3 How is the lowess curve determined?
Suppose we have data points (x1,y1), (x2,y2),...(xn,yn). Let 0 < f ≤ 1 denote a fraction that will determine the smoothness of the curve. Let r = n*f rounded to the nearest integer. Consider the tricube weight function defined as Tricube Weight Function T(t) = ( 1 - | t | 3 ) for | t | < 1 = for | t | ≥ 1. T(t) For i=1, ..., n; let hi be the rth smallest number among |xi-x1|, |xi-x2|, ..., |xi-xn|. For k=1, 2, ..., n; let wk(xi)=T( ( xk – xi ) / hi ). 3 t

4 An Example i xi yi Suppose a lowess curve will be fit to this data with f=0.4. y 4 x

5 Table Containing |xi-xj| Values
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x x x x x x x x x x 5

6 Calculation of hi from |xi-xj| Values
n=10, f=0.4  r=4 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x h1= 6 x h2= 5 x h3= 4 x h4= 5 x h5= 5 x h6= 6 x h7= 8 x h8=10 x h9=12 x h10=15 6

7 Weights wk(xi) Rounded to Nearest 0.001
i w6(x5) = (1 - ( | x6 - x5 | / h5 ) 3 ) 3 = ( 1 - ( | ( 13 – 12 ) / 5 | ) 3 ) 3 = ( 1 – 1 / 125 ) ~ ~ 7

8 Next consider local weighted regressions
For each i=1, 2, ..., n; let and denote the values of and that minimize For i=1, 2, ..., n; let and

9 9

10 10

11 11

12 12

13 13

14 14

15 15

16 16

17 17

18 18

19 Next measure the degree to which an observation is outlying.
Consider the bisquare weight function defined as B(t) = ( 1 - t 2 ) for | t | < 1 = for | t | ≥ 1. Bisquare Weight Function B(t) For k=1,2,...,n; let 19 t where s is the median of |e1|, |e2|, ..., |en|.

20 Now down-weight outlying observations
and repeat the local weighted regressions. For each i=1, 2, ..., n; let and denote the values of and that minimize . For i=1, 2, ..., n; let . 20

21 Iterate one more time. Now use the new fitted values to compute new
as described previously. Substitute the new for the old and repeat the local weighted regressions one last time to obtain the final values. These resulting values are the lowess fitted values. Plot these values versus x1, x2, ..., xn and connect with straight lines to obtain the lowess curve. 21

22 22

23 23

24 24

25 25

26 26

27 27

28 28

29 29

30 30

31 31

32 Plot Showing All 10 Lines and Predicted Values after One More Iteration
32

33 The Lowess Curve 33

34 lowess in R o=lowess(x,y,f=0.4) plot(x,y) lines(o$x,o$y,col=2,lwd=2)
o$x will be a vector containing the x values. o$y will contain the lowess fitted values for the values in o$x. f controls the fraction of the data used to obtain each fitted value. 34

35 o=lowess(y~x,f=.2) plot(fossil) lines(o,lwd=2) #See also the function 'loess' which has more #capabilities than 'lowess'.

36


Download ppt "Copyright © 2011 Dan Nettleton"

Similar presentations


Ads by Google