Learn R Programming

simest (version 0.4-1-1)

cvx.lip.reg: Convex Least Squares Regression with Lipschitz Constraint

Description

This function provides an estimate of the non-parametric regression function with a shape constraint of convexity and a smoothness constraint via a Lipschitz bound.

Usage

cvx.lip.reg(t, z, w = NULL, L, ...)

# S3 method for cvx.lip.reg plot(x, diagnostics = TRUE, ylab = quote(y ~ "and" ~ hat(y) ~ " values"), main = sprintf("Convex Lipschitz Regression\n using Least Squares, L=%g", x$L), pch = "*", cex = 1, lwd = 2, col2 = "red", ablty = 4, ...) # S3 method for cvx.lip.reg print(x, digits = getOption("digits"), ...) # S3 method for cvx.lip.reg predict(object, newdata = NULL, deriv = 0, ...)

Value

An object of class "cvx.lip.reg", basically a list with elements

x.values

sorted t values provided as input.

y.values

corresponding z 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.

residuals

residuals obtained from the fit.

minvalue

minimum value of the objective function attained.

iter

always set to 1, here.

convergence

a numeric indicating the convergence status of the code.

Arguments

t

a numeric vector giving the values of the predictor variable.

z

a numeric vector giving the values of the response variable.

w

an optional numeric vector of the same length as t; Defaults to all elements \(1/n\).

L

a numeric value providing the Lipschitz bound on the function.

...

additional arguments.

diagnostics

for the plot() method; if true, as by default, produce diagnostic, notably residual plots additionally.

main, ylab, pch, cex, lwd, col2, ablty

further optional argument to the plot() method; the last two for the color and line type of some plot components.

digits

the number of significant digits, for numbers in the print() method.

x, object

an object of class "cvx.lip.reg".

newdata

a matrix of new data points in the predict function.

deriv

a numeric either 0 or 1 representing which derivative to evaluate.

Author

Arun Kumar Kuchibhotla

Details

The function minimizes $$\sum_{i=1}^n w_i(z_i - \theta_i)^2$$ subject to $$-L \le \frac{\theta_2-\theta_1}{t_2-t_1} \le \cdots \le \frac{\theta_n-\theta_{n-1}}{t_n-t_{n-1}} \le L,$$ for sorted \(t\) values (and \(z\) permuted accordingly such that \((t_i, z_i)\) stay pairs.

This function uses the nnls function from the nnls package to perform the constrained minimization of least squares. The plot method provides the scatterplot along with fitted curve; when diagnostics = TRUE, it also includes some diagnostic plots for residuals.

The predict() method allows calculating the first derivative as well.

References

Chen, D. and Plemmons, R. J. (2009). Non-negativity Constraints in Numerical Analysis. Symposium on the Birth of Numerical Analysis.

See Also

Function nnls from CRAN package nnls.

Examples

Run this code
args(cvx.lip.reg)
x <- runif(50,-1,1)
y <- x^2 + rnorm(50,0,0.3)
tmp <- cvx.lip.reg(x, y, L = 10)
print(tmp)
plot(tmp)
predict(tmp, newdata = rnorm(10,0,0.1))

Run the code above in your browser using DataLab