# Splines in GLM and GAM

Is it wrong that splines are only available in GAM-models, and not in GLM-models? I heard this a while back, and wonder if this is just a misconception, or has some truth to it. Here is an illustration:

You are mistaken. Splines have a linear representation using derived covariates. As an example, a quadratic trend is non-linear, but can be modeled in a linear model by taking: $E[Y|X] = \beta_0 + \beta_1 X + \beta_2 X^2$, thus $X$ and its square are input into a linear model.

The spline can simply be seen as a sophisticated parametrization of one or more continuously or pseudo-continuously valued covariates.

• Thank you for answering! So by saying that I am mistaken, you mean that splines can be used in GLM, correct? Did not completely understand. – HeyJane Aug 19 '17 at 19:21
• Yes absolutely. In R, import the package splines, and running bs(...) allows you to create a linear representation of a spline with a user-specified polynomial degree and knot-points. – AdamO Aug 19 '17 at 19:32
• @HeyJane: if you look at the wikipedia page, you will note that these splines are penalized by their second derivative. This allows one to control the smoothness by a continuous penalty rather than an integer degrees of freedom. As such, it is a penalized maximum likelihood problem, rather than standard maximum likelihood problem. This means you can't fit them directly with R's glm function, unlike when using standard cubic splines with a glm. – Cliff AB Aug 19 '17 at 21:15