Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
if the gam function is the one from the package gam, it will actually do both splines and local polynomial smoothing; LOESS is a particular implementation of local polynomial smoothing with some extra stuff added on (like downweighting large residuals). – Glen_b Jan 4 at 5:40

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.