# Strictly increasing interpolation / spline

I have points in the x-y-plane that are strictly increasing most of the time. The problem is that there are cases with one or two outliers (Knots where an out-of-the-box spline would be decreasing). Without deleting any data points, is there a way to interpolate / create a spline that is strictly increasing everywhere? Also, I would like the interpolation to be $C^1$. (Which package could do this in R?)

• What is $C^1$? Other than that, it sounds like isotonic regression might be a good fit for you needs. – Sycorax Oct 29 '15 at 20:49
• mgcv can fit general penalised regression models with monotonicity constraints using cubic splines. mgcv has function mono.con for constraints on a cubic spline, and the models are fitted using the pcls() function - the help page of which has an example. – Gavin Simpson Oct 29 '15 at 21:02
• @user777 $C^1$ denotes the smoothness; maybe it is not internationally used - i studied math in Germany. (cf. en.wikipedia.org/wiki/Smoothness) – dotwin Oct 31 '15 at 2:23
• @both: upvotes + thx a bunch for your suggestions; I will look into it now. – dotwin Oct 31 '15 at 2:24
• CV user Rob Hyndman has some functions available: robjhyndman.com/software/monotonic-splines – mark999 Oct 31 '15 at 3:27

R package cobs allows you to fit shape-constrained splines, including monotonically increasing ones; syntax would be something like:

require(cobs)
fit = cobs(x,y,
constraint= "increase",
lambda=0,
degree=1, # for L1 roughness
knots=seq(min(x),max(x),length.out=10), # desired nr of knots
tau=0.5) # to predict median
preds = predict(fit,interval="none",z=xvals)[,2]


And R packages ConSpline, scar, scam and cgam offer also alternative options to fit shape-constrained splines, including monotonically increasing ones....