Description Usage Arguments Details Value Author(s) Source Examples
This function provides an estimate of the non-parametric regression function with a shape constraint of convexity and smoothness constraint provided through square integral of second derivative.
1 2 3 4 5 6 7 8 9 | cvx.pen.reg(x, y, lambda, w = NULL, tol = 1e-05, maxit = 1000,...)
## Default S3 method:
cvx.pen.reg(x, y, lambda, w = NULL, tol = 1e-05, maxit = 1000,...)
## S3 method for class 'cvx.pen.reg'
plot(x,...)
## S3 method for class 'cvx.pen.reg'
print(x,...)
## S3 method for class 'cvx.pen.reg'
predict(object, newdata = NULL,...)
|
x |
a numeric vector giving the values of the predictor variable. For |
y |
a numeric vector giving the values of the response variable. |
lambda |
a numeric value giving the penalty value. |
w |
an optional numeric vector of the same length as x; Defaults to all 1. |
maxit |
an integer giving the maxmimum number of steps taken by the algorithm; defaults to 1000. |
tol |
a numeric providing the tolerance level for convergence. |
... |
any additional arguments. |
object |
An object of class ‘cvx.pen.reg’. This is for predict function. |
newdata |
a vector of new data points to be used in the predict function. |
The function minimizes
∑_{i=1}^n w_i(y_i - f(x_i))^2 + λ\int\{f''(x)\}^2dx
subject to convexity constraint on f. plot
function provides the scatterplot along with fitted curve; it also includes some diagnostic plots for residuals. Predict function returns a matrix containing the inputted newdata along with the function values, derivatives and second derivatives.
An object of class ‘cvx.pen.reg’, basically a list including the elements
x.values |
sorted ‘x’ values provided as input. |
y.values |
corresponding ‘y’ values in input. |
fit.values |
corresponding fit values of same length as that of ‘x.values’. |
deriv |
corresponding values of the derivative of same length as that of ‘x.values’. |
iter |
number of steps taken to complete the iterations. |
residuals |
residuals obtained from the fit. |
minvalue |
minimum value of the objective function attained. |
convergence |
a numeric indicating the convergence of the code. |
alpha |
a numeric vector of length 2 less than ‘x’. This represents the coefficients of the B-splines in the second derivative of the estimator. |
AlphaMVal |
a numeric vector needed for predict function. |
lower |
a numeric vector needed for predict function. |
upper |
a numeric vector needed for predict function. |
Arun Kumar Kuchibhotla, arunku@wharton.upenn.edu, Rohit Kumar Patra, rohit@stat.columbia.edu.
Elfving, T. and Andersson, L. (1988). An Algorithm for Computing Constrained Smoothing Spline Functions. Numer. Math., 52(5):583–595.
Dontchev, A. L., Qi, H. and Qi, L. (2003). Quadratic Convergence of Newton's Method for Convex Interpolation and Smoothing. Constructive Approximation, 19(1):123-143.
1 2 3 4 5 6 7 | args(cvx.pen.reg)
x <- runif(50,-1,1)
y <- x^2 + rnorm(50,0,0.3)
tmp <- cvx.pen.reg(x, y, lambda = 0.01)
print(tmp)
plot(tmp)
predict(tmp, newdata = rnorm(10,0,0.1))
|
Loading required package: nnls
Loading required package: cobs
function (x, y, lambda, w = NULL, tol = 1e-05, maxit = 1000,
...)
NULL
Call:
cvx.pen.reg.default(x = x, y = y, lambda = 0.01)
Minimum Criterion Value Obtained:
[1] 3.078794
Number of Iterations:
[1] 7
Convergence Status:
[1] 0
newdata fun 1der 2der
[1,] 0.02235507 -0.0661781642 0.3750100 2.0956590
[2,] 0.08450423 -0.0401507128 0.4521583 0.9613187
[3,] 0.06902296 -0.0470335122 0.4368915 1.0109729
[4,] -0.18927517 -0.0845818087 -0.2017507 2.6889231
[5,] 0.08158771 -0.0414653402 0.4493410 0.9706731
[6,] 0.16644492 -0.0001673682 0.5201618 0.6985043
[7,] 0.09518042 -0.0352692462 0.4622387 0.9270761
[8,] -0.02449673 -0.0812901791 0.2648712 2.8752968
[9,] 0.10501686 -0.0306781225 0.4712027 0.8955270
[10,] 0.22266225 0.0300888114 0.5545830 0.4971582
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.