Loess

About the data:

we simulates some(x, y) data where the true signal follows one of the curves
sin(x) + cos(x), sin(x) – cos(x), sin(x) * cos(x),
.28 – .88 * x – 0.03 * x^2 + .14 * x^3.

The x range is from -pi to pi. Loess (locally weighted regression) function will help to fit a curve for set of data points that are not necessarily  linear. We need to choose smoothing parameter “span”. as span increases, the smooth curve becomes smoother.

Scatterplot of the data and  loess smooth (span= 0.75):

Plot of residuals:

To judge whether our curve (with span =0.75) is a good fit for the data, we expect that the residual plot shows no pattern. The problem is that just by looking at the residuals we may fail to spot an existing pattern. Loess curve will help again. The curve on the residual plot should be close to the horizontal line at 0 to obtain a good fit for original data and that’s why I added the loess curve (in blue) on residuals plot which shows kind of trend. That means the original data curve can be better! now will start trying less span values so the curve fits the data better.

Loess curve with span =0.5:

 

With span= 0.5, by looking at  residuals plot, we can see no pattern and the loess curve on the residual plot is almost on the horizontal line at 0 which implies that the loess curve of the original data is better here than the  previous setting where span=0.75.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *