10
$\begingroup$

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.

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

This is a tricky problem and most people just select the knots by trial and error.

One approach which is growing in popularity is to use penalized regression splines instead. Then knot selection has little effect provided you have lots of knots. The coefficients are constrained to avoid any coefficient being too large. It turns out that this is equivalent to a mixed effects model where the spline coefficients are random. Then the whole problem can be solved using REML without worrying about knot selection or a smoothing parameter.

Since you use R, you can fit such a model using the spm() function in the SemiPar package.

$\endgroup$
  • $\begingroup$ 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? $\endgroup$ – Hong Ooi Dec 30 '10 at 11:26
  • $\begingroup$ It's similar, but a different implementation, so the results are not the same. I notice that Matt Wand (author of SemiPar) comments at uow.edu.au/~mwand/SemiPar.html that mgcv now does most of what was intended for SemiPar and that he advises people use mgcv instead. $\endgroup$ – Rob Hyndman Dec 30 '10 at 12:44
7
$\begingroup$

It depends what you mean by "not too wiggly", but you might like to take a look at fractional polynomials for a simpler approach to fitting smooth curves that are not linear but not 'wiggly'. See Royston & Altman 1994 and the mfp package in R or the fracpoly command in Stata.

$\endgroup$

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