# Knot selection for cubic regression splines [duplicate]

I was wondering if anybody had experience in how to set the knot points when using cubic regression splines.

Some background: I have a response and predictor variable, and I want to determine the trend relationship between the two. To see what it looks like without making too many assumptions, I've fit a smoothing spline curve using the gam function in R. The trend is obviously not linear, but otherwise well-behaved: smooth, and not too wiggly.

I'd now like to model this trend using a simple, cubic regression spline (there are various practical issues with using the gam fit, or I'd just use that). Of course, using a regression spline requires the knots to be specified in advance. It's not too hard to do that with linear splines: I'd insert a knot where the slope of the smooth fit changes substantially, eg around local minima/maxima. However, cubic splines appear to be a more complicated story. Any guidance on where I should put the knots would be much appreciated.

• What are the practical issues in using the gam fit? – Mike Lawrence Dec 30 '10 at 10:20
• A bunch of things, but they mostly boil down to: whatever I fit has to be reproducible in SAS' proc reg. – Hong Ooi Dec 30 '10 at 11:25
• Suggest using B-splines, where the number of derivatives fit is controlled by the number of knots. – Carl Aug 17 '17 at 22:07

Since you use R, you can fit such a model using the spm() function in the SemiPar package.
• Thanks Rob. I noticed that the gam in the mgcv package can also do penalised regression splines; would that be the same as in SemiPar? – Hong Ooi Dec 30 '10 at 11:26