Extract Regression Results from a Lasso Fit

Description

Extract a regression fits from a lasso fit (table).

Usage

1
2
3
4
extract.lassogrp(object, i = NULL, lambda = NULL, data=NULL, fitfun = "lm", ...)

## S3 method for class 'lassogrp'
x[i]

Arguments

object, x

an object of class "lassogrp".

i

a single index for extract.lassogrp, or a vector of indices for the simple subset operator '[i]'

lambda

alternatively to specifying i, a single (numeric) lambda value may be specified.

data

the data originally used which must still be available. (The latter restriction will possibly be relaxed in the future.). By default it is found in the environment.

fitfun

fitting function that determines the structure of the return value. Note that coefficients and more will be taken from object.

...

additional arguments passed to fitfun.

Details

extract.lassogrp generates an object of a regression class like lm or regr. This is useful for applying the respective plot and print methods to the lasso fit. The result of an unpenalized fit to the “selected” model (terms with non-zero coefficients) is available as 'fit.unpen' component of the result.

Value

extract.lassogrp: object of class lassofit inheriting from the class specified by fitfun. $fit.unpen: The result of fitting the model (by codefitfun) to the reduced model.

x[i]: an object of class lassogrp containing only the specified fits, i.e. all the information corresponding to these fits.

Author(s)

Werner Stahel, stahel@stat.math.ethz.ch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(asphalt)
rr <- lasso(log10(RUT) ~ log10(VISC) + ASPH+BASE+FINES+VOIDS+RUN,
            data=asphalt, adaptive=TRUE)
## Extract results for three lambda's:
rr[c(1,19,20)]
extract.lassogrp(rr, 19)

## The above relies on finding the original data;
## it does not work otherwise
d.a <- asphalt
rm(asphalt)
try(extract.lassogrp(rr, lambda=2.5)) # -> error: cannot find 'asphalt'

## it works if you can specify the data :
extract.lassogrp(rr, lambda=2.5, data=d.a)