# nnlasso: Entire regularization path of non-negative penalized... In nnlasso: Non-Negative Lasso and Elastic Net Penalized Generalized Linear Models

## Description

The function computes coefficients of a penalized generalized linear model subject to non-negativity constraints for normal/binomial/poisson family using multiplicative iterative algorithm for a sequence of lambda values. Currently lasso and elastic net penalty are supported.

## Usage

 ```1 2 3``` ```nnlasso(x,y,family=c("normal","binomial","poisson"),lambda=NULL, intercept=TRUE,normalize=TRUE,tau=1,tol=1e-6,maxiter=1e5,nstep=100,min.lambda=1e-4, eps=1e-6,path=TRUE,SE=FALSE) ```

## Arguments

 `x` x is matrix of order n x p where n is number of observations and p is number of predictor variables. Rows should represent observations and columns should represent predictor variables. `y` y is a vector of response variable of order n x 1. y should follow either normal/binomial/poisson distribution. `family` family should be one of these: "normal","binomial","poisson" `lambda` The value of lambda for which coefficients are desired. The value of path must be FALSE in this case. `intercept` If TRUE, model includes intercept, else the model does not have intercept. `normalize` If TRUE, columns of x matrix are normalized with mean 0 and norm 1 prior to fitting the model. The coefficients at end are returned on the original scale. Default is normalize = TRUE. `tau` Elastic net parameter, 0 ≤ τ ≤ 1 in elastic net penalty λ{τ||β||_1+(1-τ)||β||_2^2}. Default tau = 1 corresponds to LASSO penalty. `tol` Tolerance criteria for convergence of solutions. Default is tol = 1e-6. `maxiter` Maximum number of iterations permissible for solving optimization problem for a particular lambda. Default is 10000. Rarely you need to change this to higher value. `nstep` Number of steps from maximum value of lambda to minimum value of lambda. Default is nstep = 100. `min.lambda` Minimum value of lambda. Default is min.lambda=1e-4. `eps` A small value below which a coefficient would be considered as zero. `path` Logical. If path=TRUE, entire regularization path will be obtained for a sequence of lambda values which are calculated automatically. To get coefficient estimates for a single lambda value, set path=FALSE with lambda=value. Default is path=TRUE. `SE` logical. If SE=TRUE, standard errors are produced for estimated coefficient at a given lambda. Standard errors are not produced if path=TRUE. Default is SE=FALSE.

## Value

An object of class ‘nnlasso’ with following components:

 `beta0` A vector of order nstep of intercept estimates. Each value denote an estimate for a particular lambda. Corresponding lambda values are available in ‘lambdas’ element of the ‘nnlasso’ object. `coef` A matrix of order nstep x p of slope estimates. Each row denotes solution for a particular lambda. Corresponding lambda values are available in ‘lambdas’ element of the ‘nnlasso’ object. Here p is number of predictor variables. `lambdas` Sequence of lambda values for which coefficients are obtained `L1norm` L1norm of the coefficients `norm.frac` Fractions of norm computed as L1 norm at current lambda divided by maximum L1 norm `lambda.iter` Number of iterations used for different lambdas `of.value` Objective function values `normx` Norm of x variables `se` The standard errors of coefficient estimates

## Author(s)

Baidya Nath Mandal and Jun Ma

## References

Mandal, B.N. and Ma, J. (2016). L1 regularized multiplicative iterative path algorithm for non-negative generalized linear models.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55``` ```#Non-negative LASSO data(car) attach(car) x=as.matrix(car[,1:10]) g1=nnlasso(x,y,family="normal") plot(g1) plot(g1,xvar="lambda") #Non-negative Elastic net with same data ## Not run: g2=nnlasso(x,y,family="normal",tau=0.6) plot(g2) plot(g2,xvar="lambda") ## End(Not run) #Non-negative Ridge regression with same data ## Not run: g3=nnlasso(x,y,family="normal",tau=0) plot(g3) plot(g3,xvar="lambda") ## End(Not run) #Non-negative L1 penalized GLM for binomial family ## Not run: g1=nnlasso(x,y1,family="binomial") plot(g1) plot(g1,xvar="lambda") ## End(Not run) #Non-negative Elastic net with GLM with binomial family ## Not run: g2=nnlasso(x,y1,family="binomial",tau=0.8) plot(g2) plot(g2,xvar="lambda") ## End(Not run) #coefficient estimates for a particular lambda for normal family g1=nnlasso(x,y,lambda=0.01,family="normal",path=FALSE,SE=TRUE) coef(g1) round(g1\$se,3) #coefficient estimates for a particular lambda for binomial family ## Not run: g2=nnlasso(x,y1,lambda=0.01,family="binomial",path=FALSE,SE=TRUE) coef(g2) round(g2\$se,3) detach(car) ## End(Not run) ```

### Example output

```             [,1]         [,2]         [,3]         [,4]         [,5]
[1,] 0.0009805807 0.0009805807 0.0009805807 0.0009805807 0.0009805807
[2,] 0.0863361455 0.0646818486 0.0005665369 0.0005072928 0.2568940868
[,6]         [,7]         [,8]         [,9]        [,10]
[1,] 9.805807e-04 0.0009805807 0.0009805807 0.0009805807 0.0009805807
[2,] 3.084731e-06 0.0003926049 0.0014755123 0.5104450583 0.0840079330
attr(,"scaled:scale")
Weight       Length   Wheel.base        Width Frt.Leg.Room     Front.Hd
10.19804     10.19804     10.19804     10.19804     10.19804     10.19804
Turning         Disp           HP         Tank
10.19804     10.19804     10.19804     10.19804
Weight       Length   Wheel.base        Width Frt.Leg.Room
0.000        0.285        0.212        0.213        0.250        0.120
Front.Hd      Turning         Disp           HP         Tank
0.125        0.190        0.254        0.196        0.210
[,1]         [,2]         [,3]         [,4]         [,5]
[1,] 9.805807e-04 0.0009805807 9.805807e-04 0.0009805807 0.0009805807
[2,] 7.494158e-15 1.2370524489 1.924245e-16 0.1106816166 1.6430859141
[,6]         [,7]         [,8]         [,9]        [,10]
[1,] 0.0009805807 9.805807e-04 9.805807e-04 0.0009805807 0.0009805807
[2,] 0.0000000000 1.961515e-16 1.140730e-09 1.2957991699 0.2695688762
attr(,"scaled:scale")
Weight       Length   Wheel.base        Width Frt.Leg.Room     Front.Hd
10.19804     10.19804     10.19804     10.19804     10.19804     10.19804
Turning         Disp           HP         Tank
10.19804     10.19804     10.19804     10.19804
Weight       Length   Wheel.base        Width Frt.Leg.Room
0.971        0.123        0.688        0.117        0.640        0.621
Front.Hd      Turning         Disp           HP         Tank
0.011        0.101        0.135        0.584        0.624
```

nnlasso documentation built on May 2, 2019, 8:19 a.m.