| Title: | Relaxed Lasso |
|---|---|
| Description: | Relaxed Lasso is a generalisation of the Lasso shrinkage technique for linear regression. Both variable selection and parameter estimation is achieved by regular Lasso, yet both steps do not necessarily use the same penalty parameter. The results include all standard Lasso solutions but allow often for sparser models while having similar or even slightly better predictive performance if many predictor variables are present. The package depends on the LARS package. Compatibility updates by Renova. |
| Authors: | Nicolai Meinshausen [aut, cre] |
| Maintainer: | Nicolai Meinshausen <[email protected]> |
| License: | GPL |
| Version: | 0.1.2.9001 |
| Built: | 2026-11-15 20:39:01 UTC |
| Source: | https://github.com/renova-r/relaxo |
Compute the "Relaxed Lasso" solution with minimal cross-validated L2-loss.
cvrelaxo(X, Y, K = 5, phi = seq(0, 1, length = 10), max.steps = min( 2* length(Y), 2 * ncol(X)), fast = TRUE, keep.data = TRUE, warn=TRUE)cvrelaxo(X, Y, K = 5, phi = seq(0, 1, length = 10), max.steps = min( 2* length(Y), 2 * ncol(X)), fast = TRUE, keep.data = TRUE, warn=TRUE)
X |
as in function |
Y |
as in function |
K |
Number of folds. Defaults to 5. |
phi |
as in function |
max.steps |
as in function |
fast |
as in function |
keep.data |
as in function |
warn |
as in function |
The plot method is not useful for result of cvrelaxo (as no path of solutions exists).
An object of class relaxo, for which print and predict methods exist
Nicolai Meinshausen [email protected]
N. Meinshausen, "Relaxed Lasso", Computational Statistics and Data Analysis, to appear. http://www.stat.berkeley.edu/~nicolai
See also relaxo for computation of the entire solution path
data(diabetes) ## Center and scale variables x <- scale(diabetes$x) y <- scale(diabetes$y) ## Compute "Relaxed Lasso" solution and plot results object <- relaxo(x,y) plot(object) ## Compute cross-validated solution with optimal ## predictive performance and print relaxation parameter phi and ## penalty parameter lambda of the found solution cvobject <- cvrelaxo(x,y) print(cvobject$phi) print(cvobject$lambda) ## Compute fitted values and plot them versus actual values fitted.values <- predict(cvobject) plot(fitted.values,y) abline(c(0,1))data(diabetes) ## Center and scale variables x <- scale(diabetes$x) y <- scale(diabetes$y) ## Compute "Relaxed Lasso" solution and plot results object <- relaxo(x,y) plot(object) ## Compute cross-validated solution with optimal ## predictive performance and print relaxation parameter phi and ## penalty parameter lambda of the found solution cvobject <- cvrelaxo(x,y) print(cvobject$phi) print(cvobject$lambda) ## Compute fitted values and plot them versus actual values fitted.values <- predict(cvobject) plot(fitted.values,y) abline(c(0,1))
Plot of Relaxed Lasso solutions for various relaxation parameters
## S3 method for class 'relaxo' plot(x, type = "l", lty = 1, main = NULL, xlab = "|beta|/max|beta| (phi=1)", ylab = expression("coefficients " * beta[j]), plotphi = unique(x$phi), ...)## S3 method for class 'relaxo' plot(x, type = "l", lty = 1, main = NULL, xlab = "|beta|/max|beta| (phi=1)", ylab = expression("coefficients " * beta[j]), plotphi = unique(x$phi), ...)
x |
A object of class |
type |
Plot type |
lty |
Line style |
main |
Title of plot |
xlab |
Label of x-axis |
ylab |
Label of y-axis |
plotphi |
Which values of the relaxation parameter phi should be plotted? |
... |
Arguments passed on to the plot function |
No return value
Nicolai Meinshausen [email protected]
N. Meinshausen, "Relaxed Lasso", Computational Statistics and Data Analysis, to appear. http://www.stat.berkeley.edu/~nicolai
Prediction with Relaxed Lasso
## S3 method for class 'relaxo' predict(object, newX = NULL, lambda = NULL, phi = NULL,...)## S3 method for class 'relaxo' predict(object, newX = NULL, lambda = NULL, phi = NULL,...)
object |
An object of class |
newX |
A data frame or matrix containing new data. If not given, the prediction for the original training data is returned. |
lambda |
The penalty parameter for variable selection. |
phi |
The relaxation parameter in the interval [0,1]. |
... |
other arguments (currently ignored). |
A numerical vector, containing the predictions for the new data points (or the fitted values if newX=NULL).
Nicolai Meinshausen [email protected]
N. Meinshausen, "Relaxed Lasso", Computational Statistics and Data Analysis, to appear. http://www.stat.berkeley.edu/~nicolai
Computes all "Relaxed Lasso" solutions.
relaxo(X, Y, phi = seq(0, 1, length = 4), max.steps = min(2*length(Y), 2 * ncol(X)), fast = TRUE, keep.data = TRUE, warn=TRUE)relaxo(X, Y, phi = seq(0, 1, length = 4), max.steps = min(2*length(Y), 2 * ncol(X)), fast = TRUE, keep.data = TRUE, warn=TRUE)
X |
n x p-dimensional matrix or data frame containing the predictor variables; columns are supposed to be scaled and centered. |
Y |
n-dimensional numerical response vector; supposed to be centered to mean 0. |
phi |
Relaxation parameter in [0,1]. A value of phi=1 corresponds to the regular Lasso solutions; a value of phi=0 computes the OLS estimates on the set of variables selected by the Lasso. |
max.steps |
Maximal number of steps the LARS algorithm is run. |
fast |
Should the estimates be computed in approx. the same time as the LARS algorithm? If fast=TRUE, minor deviations from the original Relaxed Lasso solution can occur. |
keep.data |
Should the data be kept for later usage e.g. (when computing predicted values for the training data) ? |
warn |
If TRUE, warnings are given if the predictor variables X are not centered and scaled or if the reponse variable is not centered) ? |
An object of class relaxo, for which plot and predict methods are available.
Nicolai Meinshausen [email protected]
N. Meinshausen, "Relaxed Lasso", Computational Statistics and Data Analysis, to appear. http://www.stat.berkeley.edu/~nicolai
See also cvrelaxo for computation of the cross-validated solution with optimal predictive performance
data(diabetes) ## Center and scale variables x <- scale(diabetes$x) y <- as.numeric(scale(diabetes$y)) ## Compute "Relaxed Lasso" solution and plot results object <- relaxo(x,y) plot(object) ## Compute cross-validated solution with optimal ## predictive performance and print relaxation parameter phi and ## penalty parameter lambda of the found solution cvobject <- cvrelaxo(x,y) print(cvobject$phi) print(cvobject$lambda) ## Compute fitted values and plot them versus actual values fitted.values <- predict(cvobject) plot(fitted.values,y) abline(c(0,1))data(diabetes) ## Center and scale variables x <- scale(diabetes$x) y <- as.numeric(scale(diabetes$y)) ## Compute "Relaxed Lasso" solution and plot results object <- relaxo(x,y) plot(object) ## Compute cross-validated solution with optimal ## predictive performance and print relaxation parameter phi and ## penalty parameter lambda of the found solution cvobject <- cvrelaxo(x,y) print(cvobject$phi) print(cvobject$lambda) ## Compute fitted values and plot them versus actual values fitted.values <- predict(cvobject) plot(fitted.values,y) abline(c(0,1))