Solved – How to determine the type of spline in GAM

generalized-additive-modelrregressionsplines

I want to model a variable in the form of

fit <- gam(y ~ x + s(z,k=-1,bs=?))

To let the function decide the ideal number of knots, I am using k=-1 but I am not able to figure out what type of spline to use. I have added a plot below. Please advise or if possible direct me to sources where I can learn about it. Thanks.

enter image description here

Best Answer

In the documentation for the mgcv package, there is a page describing the spline-based smoothers available. Moreover Wood (the package author) offers the following advice:

Broadly speaking the default penalized thin plate regression splines tend to give the best MSE performance, but they are slower to set up than the other bases.

Since in your case you have less than 200 data points, so I don't think you will run into computational issues with the default method. In section 4.1 of Wood's book "Generalized Additive Models: an introduction with R", he has a summary of the major smoothing bases (Thin plate regression splines, Duchon splines, Cubic regression splines, P-splines) available in mgcv along with a discussion of their merits and other practical considerations. I have found the book quite helpful in developing my understanding of GAMs.

Related Question