I am working in R. I want to specify flexibly a function q(X,Y) where q is strictly increasing with respect to X (but not necessarily with respect to Y). I want to use bidimensional splines but I don't know how to do (how to impose the monotonicity constraint in 2D). So far, my method is to select several values of Y, and for each values of Y, I compute a monotone splines with respect to X. And then I interpolate to create the whole function q. But I wonder if it was possible to do all this in 1 step?
The scam
package has the following capability:
smooth.construct.tesmi1.smooth.spec
: Tensor product smoothing constructor for a bivariate function monotone increasing in the first covariate
Thus
scam(z ~ s(x, y, bs = "tesmi1"), data = ...)
should fit a penalized regression spline that is monotonically increasing in x
and unconstrained with respect to y
.