Solved – GAM vs LOESS vs splines

generalized-additive-modelloessrsplines

Context: I want to draw a line in a scatterplot that doesn't appear parametric, therefore I am using geom_smooth() in ggplot in R. It automatically returns geom_smooth: method="auto" and size of largest group is >=1000, so using gam with formula: y ~ s(x, bs = "cs"). Use 'method = x' to change the smoothing method. I gather GAM stands for generalized additive models and it uses a cubic spline.

Are the following perceptions correct?

  • Loess estimates the response at specific values.

  • Splines are approximations that connect different piecewise functions that fit the data (which make up the generalized additive model), and cubic splines are the specific type of spline used here.

Lastly, When should splines be used, when should LOESS be used?

Best Answer

What matters the most is the number of effective degrees of freedom that you give to each approach. For nonparametric smoothers such as loess this is controlled by the bandwidth whereas for regression splines the d.f. are more obvious and one d.f. is spent for each knot added. Both loess and splines are estimating relationships between $X$ and $Y$. Splines are more general in the sense that they can be used in a greater variety of contexts.