# Difference between smoothing splines and splines in R

After watching this video lecture I was experimenting in R with the splines, and I saw that there is the ns and the bs.

But there is also the smoothing.spline. I thought that the splines in general, is a way to transform your variables.

So I understand how the ns and the bs work, but I do not understand how the smoothing.spline works, in the sense, why does someone need to put also as input the dependent variable variable y, instead of just putting as input only the x that you want to transform.

I had the impression that the only difference is that, by using smoothing.spline you do not have to choose the number of knots

## 1 Answer

Smoothing splines have all the knots (knots at each point), but then regularizes (shrinks the coefficients/smooths the fit) by adding a roughness penalty term (integrated squared second derivative times a smoothing parameter/tuning parameter) to the least squares criterion.

In one way, it's sort of analogous to a kind of "weighted" ridge regression, if you're prepared to regard the way the basis functions come into the penalty as weights.

Discrete versions of smoothing splines (which replace the integrated squared derivatives with summed squared differences) have a long history, dating back at least a century.

They're different from regression splines, but the two are related in various ways.

In between those you have penalized splines which have fewer than the full complement of knots but still use the roughness penalty to regularize (smooth) the fit.

I wouldn't normally regard splines as a way to transform variables but (among other things) to estimate functional relationships -- though if your interest is specifically in identifying some smooth transformation, they could be used for that.