Skip to content

Constrained cubic smoothing spline

2 messages · Victor hyk, Simon Wood

#
Victor,

It's a bit clunky, but you can use the 'pcls' function in package 'mgcv' 
for this, by adapting the examples in the help file. The examples 
themselves deal with inequality constraints imposing monotonicity, but 
'pcls' also allows you to impose equality constraints. The examples are 
based on penalized cubic regression splines (i.e. cubic splines with 
fewer knots than you have data). You could use essentially the same code 
for full smoothing splines, but it is somewhat inefficient for that 
purpose, and will be prohibitively expensive for large datasets: 
operations count is O(np^2) where p is number of spline coefficients, so 
setting p=n can get costly.

Simon
On 06/03/13 01:07, Victor hyk wrote: