demo.LocalRegression()
n <- 100
x <- seq(0, 1, length = n)*1.4
y <- 1.2 + .3*sin(5 * x) + rnorm(n) * 0.2
op <- par(mfrow=c(2,2))
LPOL(y,x, deg=0, position=5)
title("(a) moving average")
LPOL(y,x, deg=1, position=75)
title("(b) linear poly")
WLPOL(y,x, deg=2, position=30)
title("(c) quadratic poly")
WLPOL(y,x, deg=3, position= 50)
title("(b) cubic poly")
par(op)
Run the code above in your browser using DataLab