l1ce: Regression Fitting With L1-constraint on the Parameters

Description Usage Arguments Value References Examples

View source: R/l1ce.q

Description

Returns an object of class "l1ce" or "licelist" that represents fit(s) of linear models while imposing L1 constraint(s) on the parameters.

Usage

1
2
3
4
5
l1ce(formula, data = parent.frame(), weights, subset, na.action,
     sweep.out = ~ 1, x = FALSE, y = FALSE,
     contrasts = NULL, standardize = TRUE,
     trace = FALSE, guess.constrained.coefficients = double(p),
     bound = 0.5, absolute.t = FALSE)

Arguments

formula

a formula object, with the response on the left of a ~ operator, and the terms, separated by + operators, on the right.

data

a data.frame in which to interpret the variables named in the formula, the weights, the subset and the sweep.out argument. If this is missing, then the variables in the formula should be globally available.

weights

vector of observation weights. The length of weights must be the same as the number of observations. The weights must be nonnegative and it is strongly recommended that they be strictly positive, since zero weights are ambiguous, compared to use of the subset argument.

subset

expression saying which subset of the rows of the data should be used in the fit. This can be a logical vector (which is replicated to have length equal to the number of observations), or a numeric vector indicating which observation numbers are to be included, or a character vector of the row names to be included. All observations are included by default.

na.action

a function to filter missing data. This is applied to the model.frame after any subset argument has been used. The default (with na.fail) is to create an error if any missing values are found. A possible alternative is na.omit, which deletes observations that contain one or more missing values.

sweep.out

a formula object, variables whose parameters are not put under the constraint are swept out first. The variables should appear on the right of a ~ operator and be separated by + operators. Default is ~1 , i.e. the constant term is not under the constraint. If this parameter is NULL, then all parameters are put under the constraint.

x

logical indicating if the model matrix should be returned in component x.

y

logical indicating if the response should be returned in component y.

contrasts

a list giving contrasts for some or all of the factors appearing in the model formula. The elements of the list should have the same name as the variable and should be either a contrast matrix (specifically, any full-rank matrix with as many rows as there are levels in the factor), or else a function to compute such a matrix given the number of levels.

standardize

logical flag: if TRUE, then the columns of the model matrix that correspond to parameters that are constrained are standardized to have emprical variance one. The standardization is done after taking possible weights into account and after sweeping out variables whose parameters are not constrained; see vignette for details.

trace

logical flag: if TRUE, then the status during each iteration of the fitting is reported.

guess.constrained.coefficients

initial guess for the parameters that are constrained.

bound

numeric, either a single number or a vector: the constraint(s) that is/are put onto the L1 norm of the parameters.

absolute.t

logical flag: if TRUE, then bound is an absolute bound and all entries in bound can be any positive number. If FALSE, then bound is a relative bound and all entries must be between 0 and 1; see vignette for details.

Value

an object of class l1ce (if bound was a single value) or l1celist (if bound was a vector of values) is returned. See l1ce.object and l1celist.object for details.

References

Osborne, M.R., Presnell, B. and Turlach, B.A. (2000) On the LASSO and its Dual, Journal of Computational and Graphical Statistics 9(2), 319–337.

Tibshirani, R. (1996) Regression shrinkage and selection via the lasso, Journal of the Royal Statistical Society, Series B 58(1), 267–288.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data(Iowa)
l1c.I <- l1ce(Yield ~ ., Iowa, bound = 10, absolute.t=TRUE)
l1c.I

## The same, printing information in each step:
l1ce(Yield ~ ., Iowa, bound = 10, trace = TRUE, absolute.t=TRUE)

data(Prostate)
l1c.P <- l1ce(lpsa ~ ., Prostate, bound=(1:30)/30)
length(l1c.P)# 30 l1ce models
l1c.P # -- MM: too large; should do this in summary(.)!



plot(resid(l1c.I) ~ fitted(l1c.I))
abline(h = 0, lty = 3, lwd = .2)

Example output

R Package to solve regression problems while imposing
	 an L1 constraint on the parameters. Based on S-plus Release 2.1
Copyright (C) 1998, 1999
Justin Lokhorst   <jlokhors@stats.adelaide.edu.au>
Berwin A. Turlach <bturlach@stats.adelaide.edu.au>
Bill Venables     <wvenable@stats.adelaide.edu.au>

Copyright (C) 2002
Martin Maechler <maechler@stat.math.ethz.ch>
Call:
l1ce(formula = Yield ~ ., data = Iowa, bound = 10, absolute.t = TRUE)

Coefficients:
  (Intercept)          Year         Rain0         Temp1         Rain1 
-1.223687e+03  6.665384e-01  8.895341e-03  0.000000e+00  0.000000e+00 
        Temp2         Rain2         Temp3         Rain3         Temp4 
 0.000000e+00  1.700162e+00 -1.612996e-01  0.000000e+00 -2.385012e-01 

The absolute L1 bound was      : 10 
The Lagrangian for the bound is:  69.63196 
******************************
  -->	Adding variable: 1
******************************

Iteration number: 0
Value of primal object function      : 2782.530000
Value of dual   object function      : -384.942354
L1 norm of current beta              : 0.000000 <= 10.000000
Maximal absolute value in t(X)%*%r   : 3.167472e+02 attained 1 time(s)
Number of parameters allowed to vary : 1
******************************

Iteration number: 1
Value of primal object function      : 1214.892326
Value of dual   object function      : 25.579582
L1 norm of current beta              : 9.898351 <= 10.000000
Maximal absolute value in t(X)%*%r   : 1.189313e+02 attained 1 time(s)
Number of parameters allowed to vary : 1
  -->	Adding variable: 9
  -->	Stepping onto the border of the L1 ball.
******************************

Iteration number: 2
Value of primal object function      : 1088.391622
Value of dual   object function      : 509.867040
L1 norm of current beta              : 10.000000 <= 10.000000
Maximal absolute value in t(X)%*%r   : 1.155562e+02 attained 1 time(s)
Number of parameters allowed to vary : 2
  -->	Adding variable: 6
******************************

Iteration number: 3
Value of primal object function      : 1015.808773
Value of dual   object function      : 925.285484
L1 norm of current beta              : 10.000000 <= 10.000000
Maximal absolute value in t(X)%*%r   : 7.728661e+01 attained 1 time(s)
Number of parameters allowed to vary : 3
  -->	Adding variable: 7
******************************

Iteration number: 4
Value of primal object function      : 1013.514687
Value of dual   object function      : 997.935649
L1 norm of current beta              : 10.000000 <= 10.000000
Maximal absolute value in t(X)%*%r   : 7.058775e+01 attained 1 time(s)
Number of parameters allowed to vary : 4
  -->	Adding variable: 2
******************************

Iteration number: 5
Value of primal object function      : 1013.485899
Value of dual   object function      : 1013.485899
L1 norm of current beta              : 10.000000 <= 10.000000
Maximal absolute value in t(X)%*%r   : 6.963196e+01 attained 5 time(s)
Number of parameters allowed to vary : 5
Call:
l1ce(formula = Yield ~ ., data = Iowa, trace = TRUE, bound = 10, 
    absolute.t = TRUE)

Coefficients:
  (Intercept)          Year         Rain0         Temp1         Rain1 
-1.223687e+03  6.665384e-01  8.895341e-03  0.000000e+00  0.000000e+00 
        Temp2         Rain2         Temp3         Rain3         Temp4 
 0.000000e+00  1.700162e+00 -1.612996e-01  0.000000e+00 -2.385012e-01 

The absolute L1 bound was      : 10 
The Lagrangian for the bound is:  69.63196 
[1] 30
Call:
l1ce(formula = lpsa ~ ., data = Prostate, bound = (1:30)/30)

Coefficients:
      (Intercept)     lcavol    lweight          age        lbph        svi
 [1,]   2.4079829 0.05215074 0.00000000  0.000000000 0.000000000 0.00000000
 [2,]   2.3375789 0.10430149 0.00000000  0.000000000 0.000000000 0.00000000
 [3,]   2.2671749 0.15645223 0.00000000  0.000000000 0.000000000 0.00000000
 [4,]   2.1967709 0.20860298 0.00000000  0.000000000 0.000000000 0.00000000
 [5,]   2.1263669 0.26075372 0.00000000  0.000000000 0.000000000 0.00000000
 [6,]   2.0559629 0.31290446 0.00000000  0.000000000 0.000000000 0.00000000
 [7,]   1.9884010 0.36118122 0.00000000  0.000000000 0.000000000 0.01102907
 [8,]   1.9371274 0.38725659 0.00000000  0.000000000 0.000000000 0.08526449
 [9,]   1.8858539 0.41333196 0.00000000  0.000000000 0.000000000 0.15949991
[10,]   1.7462431 0.43253601 0.02752108  0.000000000 0.000000000 0.22028323
[11,]   1.5266610 0.44551948 0.07995688  0.000000000 0.000000000 0.26888842
[12,]   1.3070788 0.45850294 0.13239268  0.000000000 0.000000000 0.31749362
[13,]   1.0874967 0.47148641 0.18482849  0.000000000 0.000000000 0.36609881
[14,]   0.8679146 0.48446987 0.23726429  0.000000000 0.000000000 0.41470401
[15,]   0.7284811 0.49365402 0.26818634  0.000000000 0.009282588 0.45505849
[16,]   0.6186210 0.50024970 0.29093423  0.000000000 0.021521822 0.48803364
[17,]   0.5087610 0.50684539 0.31368212  0.000000000 0.033761056 0.52100878
[18,]   0.3989010 0.51344107 0.33643002  0.000000000 0.046000291 0.55398393
[19,]   0.4140072 0.51893849 0.35553434 -0.001664361 0.056178983 0.57442325
[20,]   0.5142130 0.52368800 0.37215748 -0.004462120 0.064954486 0.58632593
[21,]   0.6144188 0.52843752 0.38878061 -0.007259879 0.073729989 0.59822860
[22,]   0.6576089 0.53207720 0.40600224 -0.010015486 0.082086242 0.61110512
[23,]   0.6687680 0.53772360 0.41600759 -0.011756627 0.086998743 0.62829926
[24,]   0.6688581 0.54476635 0.42150088 -0.012882424 0.089863829 0.64799306
[25,]   0.6689483 0.55180911 0.42699418 -0.014008221 0.092728916 0.66768687
[26,]   0.6690384 0.55885186 0.43248747 -0.015134019 0.095594003 0.68738067
[27,]   0.6691286 0.56589462 0.43798076 -0.016259816 0.098459090 0.70707447
[28,]   0.6692187 0.57293737 0.44347406 -0.017385613 0.101324177 0.72676828
[29,]   0.6693089 0.57998013 0.44896735 -0.018511410 0.104189264 0.74646208
[30,]   0.6693990 0.58702288 0.45446064 -0.019637208 0.107054351 0.76615588
               lcp     gleason        pgg45
 [1,]  0.000000000 0.000000000 0.0000000000
 [2,]  0.000000000 0.000000000 0.0000000000
 [3,]  0.000000000 0.000000000 0.0000000000
 [4,]  0.000000000 0.000000000 0.0000000000
 [5,]  0.000000000 0.000000000 0.0000000000
 [6,]  0.000000000 0.000000000 0.0000000000
 [7,]  0.000000000 0.000000000 0.0000000000
 [8,]  0.000000000 0.000000000 0.0000000000
 [9,]  0.000000000 0.000000000 0.0000000000
[10,]  0.000000000 0.000000000 0.0000000000
[11,]  0.000000000 0.000000000 0.0000000000
[12,]  0.000000000 0.000000000 0.0000000000
[13,]  0.000000000 0.000000000 0.0000000000
[14,]  0.000000000 0.000000000 0.0000000000
[15,]  0.000000000 0.000000000 0.0001812107
[16,]  0.000000000 0.000000000 0.0005707550
[17,]  0.000000000 0.000000000 0.0009602994
[18,]  0.000000000 0.000000000 0.0013498437
[19,]  0.000000000 0.000000000 0.0017000959
[20,]  0.000000000 0.000000000 0.0020235909
[21,]  0.000000000 0.000000000 0.0023470858
[22,]  0.000000000 0.008508797 0.0025069611
[23,] -0.008582305 0.015186708 0.0027130057
[24,] -0.022423914 0.019465173 0.0029719083
[25,] -0.036265523 0.023743639 0.0032308108
[26,] -0.050107133 0.028022104 0.0034897134
[27,] -0.063948742 0.032300569 0.0037486160
[28,] -0.077790351 0.036579034 0.0040075185
[29,] -0.091631960 0.040857499 0.0042664211
[30,] -0.105473570 0.045135964 0.0045253236

Relative and absolute L1 bounds and the Lagrangians:
       rel.bound  abs.bound   Lagrangian
 [1,] 0.03333333 0.06146616 7.548890e+01
 [2,] 0.06666667 0.12293233 6.958815e+01
 [3,] 0.10000000 0.18439849 6.368740e+01
 [4,] 0.13333333 0.24586466 5.778665e+01
 [5,] 0.16666667 0.30733082 5.188590e+01
 [6,] 0.20000000 0.36879698 4.598514e+01
 [7,] 0.23333333 0.43026315 4.028653e+01
 [8,] 0.26666667 0.49172931 3.574636e+01
 [9,] 0.30000000 0.55319548 3.120619e+01
[10,] 0.33333333 0.61466164 2.747686e+01
[11,] 0.36666667 0.67612780 2.448159e+01
[12,] 0.40000000 0.73759397 2.148631e+01
[13,] 0.43333333 0.79906013 1.849104e+01
[14,] 0.46666667 0.86052630 1.549576e+01
[15,] 0.50000000 0.92199246 1.305806e+01
[16,] 0.53333333 0.98345862 1.089104e+01
[17,] 0.56666667 1.04492479 8.724026e+00
[18,] 0.60000000 1.10639095 6.557010e+00
[19,] 0.63333333 1.16785712 5.138082e+00
[20,] 0.66666667 1.22932328 4.228589e+00
[21,] 0.70000000 1.29078944 3.319095e+00
[22,] 0.73333333 1.35225561 2.440644e+00
[23,] 0.76666667 1.41372177 1.938086e+00
[24,] 0.80000000 1.47518794 1.661216e+00
[25,] 0.83333333 1.53665410 1.384347e+00
[26,] 0.86666667 1.59812026 1.107478e+00
[27,] 0.90000000 1.65958643 8.306082e-01
[28,] 0.93333333 1.72105259 5.537388e-01
[29,] 0.96666667 1.78251876 2.768694e-01
[30,] 1.00000000 1.84398492 7.549517e-15

lasso2 documentation built on Oct. 8, 2021, 9:10 a.m.