Title: | Nonparametric, Tuning-Free Estimation of S-Shaped Functions |
---|---|
Description: | Estimation of an S-shaped function and its corresponding inflection point via a least squares approach. A sequential mixed primal-dual based algorithm is implemented for the fast computation. Details can be found in Feng et al. (2022) <doi:10.1111/rssb.12481>. |
Authors: | Oliver Y. Feng [aut], Yining Chen [aut, cre], Qiyang Han [aut], Raymond J. Carroll [aut], Richard J. Samworth [aut] |
Maintainer: | Yining Chen <[email protected]> |
License: | GPL-2 |
Version: | 1.1 |
Built: | 2024-11-08 06:16:04 UTC |
Source: | CRAN |
Estimation of an S-shaped function and its corresponding inflection point via a least squares approach. A sequential mixed primal-dual bases algorithm is implemented for the fast computation of the estimator. The same algorithm can also be used to solve other shape-restricted regression problems, such as convex regression. See Fraser and Massam (1989) and Feng et al. (2022).
Consider the nonparametric estimation of an S-shaped regression function. The least squares estimator provides a very natural, tuning-free approach, but results in a non-convex optimisation problem, since the inflection point is unknown. Nevertheless, the estimator may be regarded as a projection onto a finite union of convex cones, which allows us to propose a mixed primal-dual bases algorithm for its efficient, sequential computation.
In the current version of the package, we use this algorithm to implement the least squares regression estimator under the following shape-restrictions: S-shaped functions, i.e. increasing convex to the left of the inflection point and increasing concave to the right of the inflection point; and increasing and convex functions (as a by-product of the former). The corresponding plot and predict methods are also included. In the future, we plan to also include the estimation of additive S-shaped functions, where the covariates are multivariate for the regression.
Fraser, D. A. S. and Massam, H. (1989). A mixed primal-dual bases algorithm for regression under inequality constraints. Application to concave regression. Scandinavian Journal of Statistics, Volume 16, Pages 65-74.
Feng, O. Y., Chen, Y., Han, Q., Carroll, R. J. and Samworth, R. J. (2022). Nonparametric, tuning-free estimation of S-shaped functions. Journal of the Royal Statistical Society: Series B (Statistical Methodology), Volume 84, Issue 4, Pages 1324-1352. <doi:10.1111/rssb.12481>
# Generate data set.seed(1) x <- seq(-1,1,0.005) y <- sin(x*pi/2) + rnorm(length(x)) # Fit S-shape output <- sshapedreg(x,y) # Plot plot(output) # prediction at new design points xnew=rnorm(5) predict(output,xnew)
# Generate data set.seed(1) x <- seq(-1,1,0.005) y <- sin(x*pi/2) + rnorm(length(x)) # Fit S-shape output <- sshapedreg(x,y) # Plot plot(output) # prediction at new design points xnew=rnorm(5) predict(output,xnew)
This function computes the least squares increasing and convex regression estimator by a sequential mixed primal-dual bases algorithm.
cvxreg(x,y)
cvxreg(x,y)
x |
a numeric vector that contains all the design points. NB. for the current version, we require all values to be distinct (but not necessarily in ascending order). |
y |
a numeric vector that contains the values of the response with respect to the design points. |
For more details, see Sshaped
.
An object of class sshaped
, which contains the following fields:
x |
covariates copied from input |
y |
response copied from input |
fitted |
the fitted values of the regression function with respect to the design points. |
rss |
the value of the minimised residual sum of squares of the fit |
inflection |
the location of the inflection point, which equals |
shape |
the shape enforced in the fit, here equals " |
x<-seq(0,5,0.01) y<-x^2 + rnorm(length(x)) output<-cvxreg(x,y) plot(output) xnew=rexp(5); predict(output,xnew)
x<-seq(0,5,0.01) y<-x^2 + rnorm(length(x)) output<-cvxreg(x,y) plot(output) xnew=rexp(5); predict(output,xnew)
sshaped
objectThis function takes a fitted sshaped
object produced
by sshapedreg
or cvxreg
, and plots the observations, the fitted function and the location of the estimated inflection point (where applicable).
## S3 method for class 'sshaped' plot(x, ...)
## S3 method for class 'sshaped' plot(x, ...)
x |
A fitted |
... |
Other arguments passed to |
A plot that shows the observations, the fitted function and the location of the estimated inflection point (where applicable, i.e. when object$shape
equals "sshaped
".).
No return value. A plot is produced.
## See examples for the functions sshapedreg and cvxreg.
## See examples for the functions sshapedreg and cvxreg.
sshaped
fit
This function obtains predictions at new design points from a fitted sshaped
object.
## S3 method for class 'sshaped' predict(object, xnew, ...)
## S3 method for class 'sshaped' predict(object, xnew, ...)
object |
A fitted |
xnew |
An optional numeric |
... |
Other arguments passed to |
A numeric vector containing predictions at new data points.
## See examples for the functions sshapedreg and cvxreg.
## See examples for the functions sshapedreg and cvxreg.
This function computes the least squares S-shaped regression estimator and its corresponding inflection point by a sequential mixed primal-dual bases algorithm.
sshapedreg(x,y)
sshapedreg(x,y)
x |
a numeric vector that contains all the design points. NB. for the current version, we require all values to be distinct (but not necessarily in ascending order). |
y |
a numeric vector that contains the values of the response with respect to the design points. |
For more details, see Sshaped
.
An object of class sshaped
, which contains the following fields:
x |
covariates copied from input |
y |
response copied from input |
fitted |
the fitted values of the regression function with respect to the design points. |
rss |
the value of the minimised residual sum of squares of the fit |
inflection |
the estimated location of the inflection point |
shape |
the shape enforced in the fit, here equals " |
x<-seq(-1,1,0.005) y<-sin(x*pi/2) + rnorm(length(x)) output<-sshapedreg(x,y) plot(output) xnew=rnorm(5); predict(output,xnew)
x<-seq(-1,1,0.005) y<-sin(x*pi/2) + rnorm(length(x)) output<-sshapedreg(x,y) plot(output) xnew=rnorm(5); predict(output,xnew)