Solved – LOESS smoothing fit

loesssmoothing

Here are 3 questions about the LOESS smoothing fit.

# Loess model
plot(Y ~ X)
loess.model <- loess(Dataset$Y ~ Dataset$X)
loess.model
hat <- predict(loess.model)
lines(Dataset$X[order(Dataset$X)], hat[order(Dataset$X)], col="red")  


Number of Observations: 52
Equivalent Number of Parameters: 4.62
Residual Standard Error: 0.9877
  1. Is it possible to get the R-square of the loess fit (red curve)? If yes, how can I get the R-square? Could you give me the R code?
  2. It is impossible to get the equation of the smoothing fit (red curve). Therefore we can not do any prediction with a smoothing fit LOESS? On the contrary we can easily do/make prediction with the linear line.
  3. What is the main purpose to use a smoothing fit instead of a linear line? Is the smoothing fit more accurate, although we can not do any prediction?

Best Answer

There is a function in the TeachingDemos package called loess.demo that helps with the understanding of loess models, reading the documentation and running that function a few times may help with your understanding.

1) One way to get an R-square value is to square the correlation between the original y-values and the predicted y-values at the same point (what you call hat). Of course, since there is discussion about the validity of R-square values for regular linear regression you should be cautious of any interpretation here.

2) It is not impossible to get the equation of the smooth curve (finding meaning from it is another thing). And just because you don't have the equation does not mean that you cannot make predictions, your code uses the predict function on a loess object to get the curve, you can also use predict on new x values as well.

3) Again you misunderstand, predictions are possible (just not in as simple an equation as linear regression). Loess lines can also suggest possible transformations that may make the relationship linear, loess lines give an overall feel for the relationship, a loess line with confidence interval can tell you if the curvature is real/important or if a straight line would probably fit as well and any curvature is due to chance. Loess (and other smooths) have many uses in exploratory statistics.

Related Question