extlasso | R Documentation |
The function computes coefficients of a penalized generalized linear model for normal/binomial/poisson family using modified Jacobi Algorithm for a sequence of lambda values. Currently lasso and elastic net penalty are supported.
extlasso(x,y,family=c("normal","binomial","poisson"),intercept=TRUE, normalize=TRUE,tau=1,alpha=1e-12,eps=1e-6,tol=1e-6,maxiter=1e5, nstep=100,min.lambda=1e-4)
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" |
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. |
alpha |
The quantity in approximating |β_j| = √(β_j^2+α) Default is alpha = 1e-12. |
eps |
A value which is used to set a coefficient to zero if coefficients value is within - eps to + eps. Default is eps = 1e-6. |
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. |
An object of class ‘extlasso’ 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 ‘extlasso’ 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 ‘extlasso’ 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 |
B N Mandal and Jun Ma
Mandal, B.N. and Jun Ma, (2014). A Jacobi-Armijo Algorithm for LASSO and its Extensions.
#LASSO x=matrix(rnorm(100*30),100,30) y=rnorm(100) g1=extlasso(x,y,family="normal") plot(g1) plot(g1,xvar="lambda") #Elastic net g2=extlasso(x,y,family="normal",tau=0.6) plot(g2) plot(g2,xvar="lambda") #Ridge regression g3=extlasso(x,y,family="normal",tau=0) plot(g3) plot(g3,xvar="lambda") #L1 penalized GLM for binomial family x=matrix(rnorm(100*30),100,30) y=sample(c(0,1),100,replace=TRUE) g1=extlasso(x,y,family="binomial") plot(g1) plot(g1,xvar="lambda") #Elastic net with GLM with binomial family g2=extlasso(x,y,family="binomial",tau=0.8) plot(g2) plot(g2,xvar="lambda")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.