extract.lassogrp: Extract Regression Results from a Lasso Fit

Description Usage Arguments Details Value Author(s) Examples

View source: R/lassogrp.R

Description

Extract a regression fit from a lasso fit (table) of class "linkS4class{lassogrp}".

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 "linkS4class{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 (S3) class "lassofit", also inheriting from the class specified by fitfun. Component fit.unpen: The result of fitting the model (by fitfun) 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
16
17
18
data(asphalt)
rr <- lasso(log10(RUT) ~ log10(VISC) + ASPH+BASE+FINES+VOIDS+RUN,
            data=asphalt, adaptive=TRUE)
length(rr$lambda) # 21
## Extract results for three lambda's (currently works wrongly!)
rr[c(1,19,20)] 

extract.lassogrp(rr,  2)
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)

lassogrp documentation built on July 25, 2021, 3 a.m.