Learn R Programming

relaxo (version 0.1-2)

relaxo: Relaxed Lasso (relaxo)

Description

Computes all "Relaxed Lasso" solutions.

Usage

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)

Arguments

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) ?

Value

An object of class relaxo, for which plot and predict methods are available.

References

N. Meinshausen, "Relaxed Lasso", Computational Statistics and Data Analysis, to appear. http://www.stat.berkeley.edu/~nicolai

See Also

See also cvrelaxo for computation of the cross-validated solution with optimal predictive performance

Examples

Run this code
	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))

Run the code above in your browser using DataLab