A symbolic routine to define that a surface is decreasing in one predictor and increasing in another in a formula argument to cgam.
s.incr.decr(x1, x2, numknots = c(0, 0), knots = list(k1 = 0, k2 = 0), space = c("E", "E"))
The vectors
A numeric predictor which has the same length as the response vector.
A numeric predictor which has the same length as the response vector.
A vector of the number of knots used to constrain
A list of two vectors of knots used to constrain
A vector of the character specifying the method to create knots for
Mary C. Meyer and Xiyue Liao
"s.incr.decr" returns the vectors "x1" and "x2", and imposes on each vector six attributes: name, shape, numknots, knots, space and decreasing.
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.incr.decr"; the shape attribute is "wps_id"(increasing-decreasing); the decreasing values for "x1" and "x2" are TRUE and FALSE. According to the value of the vector itself and its shape, numknots, knots, space and decreasing attributes, the cone edges will be made by warped-plane spline basis functions in Meyer (2016). The cone edges are a set of basis employed in the hinge algorithm.
Note that "s.incr.decr" does not make the corresponding cone edges itself. It sets things up to a subroutine called makedelta_wps.
See references cited in this section for more details.
Meyer, M. C. (2017) Estimation and inference for regression surfaces using shape-constrained splines.
s.incr.incr
, s.decr.decr
, s.decr.incr
, cgam
if (FALSE) {
# generate data
n <- 100
set.seed(123)
x1 <- runif(n)
x2 <- runif(n)
y <- 4 * (x1 - x2) - x1 * x2 + rnorm(n, sd = .2)
# regress y on x1 and x2 under the shape-restriction: "increasing-decreasing"
# using the penalized estimator
ans <- cgam(y ~ s.incr.decr(x1, x2), pnt = TRUE)
# make a 3D plot of the constrained surface
plotpersp(ans)
}
Run the code above in your browser using DataLab