# s.conv.conv: Specify a Doubly-convex Shape-Restriction in a CGAM Formula In cgam: Constrained Generalized Additive Model

## Description

A symbolic routine to define that a surface is convex in two predictors in a formula argument to cgam.

## Usage

 `1` ```s.conv.conv(x1, x2, numknots = c(0, 0), knots = list(k1 = 0, k2 = 0), space = c("E", "E")) ```

## Arguments

 `x1` A numeric predictor which has the same length as the response vector. `x2` A numeric predictor which has the same length as the response vector. `numknots` A vector of the number of knots used to constrain x_1 and x_2. It will not be used if the user specifies the knots argument and each predictor is within the range of its knots. The default is numknots = c(0, 0). `knots` A list of two vectors of knots used to constrain x_1 and x_2. User-defined knots will be used if each predictor is within the range of its knots. Otherwise, numknots and space will be used to create knots. The default is knots = list(k1 = 0, k2 = 0). `space` A vector of the character specifying the method to create knots for x_1 and x_2. It will not be used if the user specifies the knots argument. If "E" is used, then equally spaced knots will be created; if "Q" is used, then a vector of equal quantiles will be created with duplicate elements removed. The number of knots is numknots when numknots is a positive integer > 4. Otherwise it is of the order n^{1/3}. The default is space = c("E", "E").

## Details

"s.conv.conv" returns the vectors "x1" and "x2", and imposes on each vector six attributes: name, shape, numknots, knots, space and cvs.

The name attribute is used in the subroutine plotpersp; the numknots, knots and space attributes are the same as the numknots, knots and space arguments in "s.conv.conv"; the shape attribute is "tri_cvs"(doubly-convex); the cvs values for both vectors are TRUE. According to the value of the vector itself and its shape, numknots, knots, space and cvs attributes, the cone edges will be made by triangle spline basis functions in Meyer (2017). The cone edges are a set of basis employed in the hinge algorithm.

Note that "s.conv.conv" does not make the corresponding cone edges itself. It sets things up to a subroutine called trispl.fit

See references cited in this section for more details.

## Value

The vectors x_1 and x_2. Each of them has six attributes, i.e., name: names of x_1 and x_2; shape: "tri_cvs"(doubly-convex); numknots: the numknots argument in "s.conv.conv"; knots: the knots argument in "s.conv.conv"; space: the space argument in "s.conv.conv"; cvs: two logical values indicating the monotonicity of the isotonically-constrained surface with respect to x_1 and x_2, which are both TRUE.

## Author(s)

Mary C. Meyer and Xiyue Liao

## References

Meyer, M. C. (2017) Estimation and inference for regression surfaces using shape-constrained splines.

`s.conv.conv`, `cgam`
 ``` 1 2 3 4 5 6 7 8 9 10``` ``` # generate data n <- 200 set.seed(123) x1 <- runif(n); x2 <- runif(n) y <- (x1 - 1)^2 + (x2 - 3)^2 + rnorm(n) # regress y on x1 and x2 under the shape-restriction: "doubly-convex" ans <- cgam(y ~ s.conv.conv(x1, x2), nsim = 0) # make a 3D plot of the constrained surface plotpersp(ans) ```