Home | About | Journals | Submit | Contact Us | Français |

**|**HHS Author Manuscripts**|**PMC2929880

Formats

Article sections

- Abstract
- 1 Introduction
- 2 Algorithms for the Lasso, Ridge Regression and the Elastic Net
- 3 Regularized Logistic Regression
- 4 Regularized Multinomial Regression
- 5 Timings
- 6 Discussion
- References

Authors

Related links

J Stat Softw. Author manuscript; available in PMC 2010 August 30.

Published in final edited form as:

J Stat Softw. 2010; 33(1): 1–22.

PMCID: PMC2929880

NIHMSID: NIHMS201118

Department of Statistics, Stanford University

See other articles in PMC that cite the published article.

We develop fast algorithms for estimation of generalized linear models with convex penalties. The models include linear regression, two-class logistic regression, and multinomial regression problems while the penalties include _{1} (the lasso), _{2} (ridge regression) and mixtures of the two (the elastic net). The algorithms use cyclical coordinate descent, computed along a regularization path. The methods can handle large problems and can also deal efficiently with sparse features. In comparative timings we find that the new algorithms are considerably faster than competing methods.

The lasso [Tibshirani, 1996] is a popular method for regression that uses an _{1} penalty to achieve a sparse solution. In the signal processing literature, the lasso is also known as *basis pursuit* [Chen et al., 1998]. This idea has been broadly applied, for example to generalized linear models [Tibshirani, 1996] and Cox’s proportional hazard models for survival data [Tibshirani, 1997]. In recent years, there has been an enormous amount of research activity devoted to related regularization methods:

- The grouped lasso [Yuan and Lin, 2007, Meier et al., 2008], where variables are included or excluded in groups;
- The Dantzig selector [Candes and Tao, 2007, and discussion], a slightly modified version of the lasso;
- The
*elastic net*[Zou and Hastie, 2005] for correlated variables, which uses a penalty that is part_{1}, part_{2}; _{1}regularization paths for generalized linear models [Park and Hastie, 2007];- Regularization paths for the support-vector machine [Hastie et al., 2004].
- The graphical lasso [Friedman et al., 2008] for sparse covariance estimation and undirected graphs

Efron et al. [2004] developed an efficient algorithm for computing the entire regularization path for the lasso. Their algorithm exploits the fact that the coefficient profiles are piecewise linear, which leads to an algorithm with the same computational cost as the full least-squares fit on the data (see also Osborne et al. [2000]).

In some of the extensions above [2,3,5], piecewise-linearity can be exploited as in Efron et al. [2004] to yield efficient algorithms. Rosset and Zhu [2007] characterize the class of problems where piecewise-linearity exists—both the loss function and the penalty have to be quadratic or piecewise linear.

Here we instead focus on cyclical coordinate descent methods. These methods have been proposed for the lasso a number of times, but only recently was their power fully appreciated. Early references include Fu [1998], Shevade and Keerthi [2003] and Daubechies et al. [2004]. Van der Kooij [2007] independently used coordinate descent for solving elastic-net penalized regression models. Recent rediscoveries include Friedman et al. [2007] and Wu and Lange [2008a]. The first paper recognized the value of solving the problem along an entire path of values for the regularization parameters, using the current estimates as warm starts. This strategy turns out to be remarkably efficient for this problem. Several other researchers have also re-discovered coordinate descent, many for solving the same problems we address in this paper—notably Shevade and Keerthi [2003], Krishnapuram and Hartemink [2005], Genkin et al. [2007] and Wu et al. [2009].

In this paper we extend the work of Friedman et al. [2007] and develop fast algorithms for fitting generalized linear models with elastic-net penalties. In particular, our models include regression, two-class logistic regression, and multinomial regression problems. Our algorithms can work on very large datasets, and can take advantage of sparsity in the feature set. We provide a publicly available R package glmnet. We do not revisit the well-established convergence properties of coordinate descent in convex problems [Tseng, 2001] in this article.

Lasso procedures are frequently used in domains with very large datasets, such as genomics and web analysis. Consequently a focus of our research has been algorithmic efficiency and speed. We demonstrate through simulations that our procedures outperform all competitors — even those based on coordinate descent.

In section 2 we present the algorithm for the elastic net, which includes the lasso and ridge regression as special cases. Section 3 and 4 discuss (two-class) logistic regression and multinomial logistic regression. Comparative timings are presented in Section 5.

We consider the usual setup for linear regression. We have a response variable *Y* and a predictor vector *X* ^{p}, and we approximate the regression function by a linear model *E*(*Y*|*X* = *x*) = β_{0} + x^{T} β. We have *N* observation pairs (*x _{i}*,

$$\underset{({\beta}_{0},\beta )\in {\mathbb{R}}^{p+1}}{\text{min}}\left[\frac{1}{2N}{\displaystyle \sum _{i=1}^{N}{({y}_{i}-{\beta}_{0}-{x}_{i}^{T}\beta )}^{2}+\lambda {P}_{\alpha}(\beta )}\right],$$

(1)

where

$${P}_{\alpha}\phantom{\rule{thinmathspace}{0ex}}(\beta )=(1-\alpha )\frac{1}{2}{\Vert \beta \Vert}_{{\ell}_{2}}^{2}+\alpha {\Vert \beta \Vert}_{{\ell}_{1}}$$

(2)

$$={\displaystyle \sum _{j=1}^{p}\left[\frac{1}{2}(1-\alpha ){\beta}_{j}^{2}+\alpha \left|{\beta}_{j}\right|\right]}$$

(3)

is the *elastic-net penalty* [Zou and Hastie, 2005]. *P*_{α} is a compromise between the ridge-regression penalty (α = 0) and the lasso penalty (α = 1). This penalty is particularly useful in the *p* *N* situation, or any situation where there are many correlated predictor variables.

Ridge regression is known to shrink the coefficients of correlated predictors towards each other, allowing them to borrow strength from each other. In the extreme case of *k* identical predictors, they each get identical coefficients with 1/*k*th the size that any single one would get if fit alone. From a Bayesian point of view, the ridge penalty is ideal if there are many predictors, and all have non-zero coefficients (drawn from a Gaussian distribution).

Lasso, on the other hand, is somewhat indifferent to very correlated predictors, and will tend to pick one and ignore the rest. In the extreme case above, the lasso problem breaks down. The Lasso penalty corresponds to a Laplace prior, which expects many coefficients to be close to zero, and a small subset to be larger and nonzero.

The elastic net with α = 1 − ε for some small ε > 0 performs much like the lasso, but removes any degeneracies and wild behavior caused by extreme correlations. More generally, the entire family *P*_{α} creates a useful compromise between ridge and lasso. As α increases from 0 to 1, for a given λ the sparsity of the solution to (1) (i.e. the number of coefficients equal to zero) increases monotonically from 0 to the sparsity of the lasso solution.

Figure 1 shows an example. The dataset is from [Golub et al., 1999b], consisting of 72 observations on 3571 genes measured with DNA microarrays. The observations fall in two classes: we treat this as a regression problem for illustration. The coefficient profiles from the first 10 steps (grid values for λ) for each of the three regularization methods are shown. The lasso admits at most *N* = 72 genes into the model, while ridge regression gives all 3571 genes non-zero coefficients. The elastic net provides a compromise between these two methods, and has the effect of averaging genes that are highly correlated and then entering the averaged gene into the model. Using the algorithm described below, computation of the entire path of solutions for each method, at 100 values of the regularization parameter evenly spaced on the log-scale, took under a second in total. Because of the large number of non-zero coefficients for ridge regression, they are individually much smaller than the coefficients for the other methods.

Leukemia data: profiles of estimated coefficients for three methods, showing only first 10 steps (values for λ) in each case. For the elastic net, α = 0.2.

Consider a coordinate descent step for solving (1). That is, suppose we have estimates _{0} and _{} for ≠ *j*, and we wish to partially optimize with respect to β_{j}. Denote by *R*(β_{0}, β) the objective function in (1). We would like to compute the gradient at β_{j} = _{j}, which only exists if _{j} ≠ 0. If _{j} > 0, then

$$\frac{\partial R}{\partial {\beta}_{j}}{|}_{\beta =\tilde{\beta}}=-\frac{1}{N}{\displaystyle \sum _{i=1}^{N}{x}_{\mathit{\text{ij}}\phantom{\rule{thinmathspace}{0ex}}}({y}_{i}-{\tilde{\beta}}_{o}-{x}_{i}^{T}\tilde{\beta})}+\lambda (1-\alpha ){\beta}_{j}+\lambda \alpha .$$

(4)

A similar expression exists if _{j} < 0, and _{j} = 0 is treated separately. Simple calculus shows [Donoho and Johnstone, 1994] that the coordinate-wise update has the form

$${\tilde{\beta}}_{j}\leftarrow \frac{S\phantom{\rule{thinmathspace}{0ex}}\left(\frac{1}{N}{\displaystyle {\sum}_{i=1}^{N}{x}_{\mathit{\text{ij}}\phantom{\rule{thinmathspace}{0ex}}}({y}_{i}\phantom{\rule{thinmathspace}{0ex}}-\phantom{\rule{thinmathspace}{0ex}}{\tilde{y}}_{i}^{(j)}),\phantom{\rule{thinmathspace}{0ex}}\lambda \alpha}\right)}{1+\lambda \phantom{\rule{thinmathspace}{0ex}}(1-\alpha )}$$

(5)

where

- ${\tilde{y}}_{i}^{(j)}={\tilde{\beta}}_{0}+{\displaystyle {\sum}_{\ell \ne j}{x}_{i\ell}{\tilde{\beta}}_{\ell}}$ is the fitted value excluding the contribution from
*x*, and hence ${y}_{i}-{\tilde{y}}_{i}^{(j)}$ the_{ij}*partial residual*for fitting β_{j}. Because of the standardization, $\frac{1}{N}{\displaystyle {\sum}_{i=1}^{n}{x}_{\mathit{\text{ij}}\phantom{\rule{thinmathspace}{0ex}}}({y}_{i}-{\tilde{y}}_{i}^{(j)})}$ is the simple least-squares coefficient when fitting this partial residual to*x*_{ij}. *S*(*z*, γ) is the soft-thresholding operator with value$$\text{sign}(z)\phantom{\rule{thinmathspace}{0ex}}(\left|z\right|-\gamma )+=\{\begin{array}{cc}z-\gamma \hfill & \text{if}\phantom{\rule{thinmathspace}{0ex}}z\phantom{\rule{thinmathspace}{0ex}}>0\text{and}\gamma \left|z\right|\hfill \\ z+\gamma \hfill & \text{if}\phantom{\rule{thinmathspace}{0ex}}z\phantom{\rule{thinmathspace}{0ex}}0\text{and}\gamma \left|z\right|\hfill \\ 0\hfill & \text{if}\phantom{\rule{thinmathspace}{0ex}}\gamma \phantom{\rule{thinmathspace}{0ex}}\ge \left|z\right|.\hfill \end{array}$$(6)

The details of this derivation are spelled out in Friedman et al. [2007].

Thus we compute the simple least-squares coefficient on the partial residual, apply soft-thresholding to take care of the lasso contribution to the penalty, and then apply a proportional shrinkage for the ridge penalty. This algorithm was suggested by Van der Kooij [2007].

Looking more closely at (5), we see that

$$\begin{array}{cc}{y}_{i}-{\tilde{y}}_{i}^{(j)}\hfill & ={y}_{i}-{\widehat{y}}_{i}+{x}_{\mathit{\text{ij}}}{\tilde{\beta}}_{j}\hfill \\ \hfill & ={r}_{i}+{x}_{\mathit{\text{ij}}}{\tilde{\beta}}_{j},\hfill \end{array}$$

(7)

where *ŷ*_{i} is the current fit of the model for observation *i*, and hence *r*_{i} the current residual. Thus

$$\frac{1}{N}{\displaystyle \sum _{i=1}^{N}{x}_{\mathit{\text{ij}}\phantom{\rule{thinmathspace}{0ex}}}({y}_{i}-{\tilde{y}}_{i}^{(j)})=\frac{1}{N}}{\displaystyle \sum _{i=1}^{N}{x}_{\mathit{\text{ij}}\phantom{\rule{thinmathspace}{0ex}}}{r}_{i}+{\tilde{\beta}}_{j},}$$

(8)

because the *x*_{j} are standardized. The first term on the right-hand side is the gradient of the loss with respect to β_{j}. It is clear from (8) why coordinate descent is computationally efficient. Many coefficients are zero, remain zero after the thresholding, and so nothing needs to be changed. Such a step costs *O*(*N*) operations— the sum to compute the gradient. On the other hand, if a coefficient does change after the thresholding, *r*_{i} is changed in *O*(*N*) and the step costs *O*(2*N*). Thus a complete cycle through all *p* variables costs *O*(*pN*) operations. We refer to this as the *naive algorithm*, since it is generally less efficient than the *covariance updating* algorithm to follow. Later we use these algorithms in the context of iteratively reweighted least squares (IRLS), where the observation weights change frequently; there the naive algorithm dominates.

Further efficiencies can be achieved in computing the updates in (8). We can write the first term on the right (up to a factor 1/*N*) as

$$\sum _{i=1}^{N}{x}_{\mathit{\text{ij}}}{r}_{i}=\langle {x}_{j},y\rangle -{\displaystyle \sum _{k:\left|{\tilde{\beta}}_{k}\right|>0}\langle {x}_{j},{x}_{k}\rangle}}{\tilde{\beta}}_{k},$$

(9)

where $\langle {x}_{j},y\rangle ={\displaystyle {\sum}_{i=1}^{N}{x}_{\mathit{\text{ij}}}{y}_{i}.}$ Hence we need to compute inner products of each feature with *y* initially, and then each time a new feature *x*_{k} enters the model (for the first time), we need to compute and store its inner product with all the rest of the features (*O*(*N _{p}*) operations). We also store the

We are sometimes faced with problems where the *N* × *p* feature matrix *X* is extremely sparse. A leading example is from document classification, where the feature vector uses the so-called “bag-of-words” model. Each document is scored for the presence/absence of each of the words in the entire dictionary under consideration (sometimes counts are used, or some transformation of counts). Since most words are absent, the feature vector for each document is mostly zero, and so the entire matrix is mostly zero. We store such matrices efficiently in *sparse column format*, where we store only the non-zero entries and the coordinates where they occur.

Coordinate descent is ideally set up to exploit such sparsity, in an obvious way. The *O*(*N*) inner-product operations in either the naive or covariance updates can exploit the sparsity, by summing over only the non-zero entries. Note that in this case scaling of the variables will not alter the sparsity, but centering will. So scaling is performed up front, but the centering is incorporated in the algorithm in an efficient and obvious manner.

Often a weight *w*_{i} (other than 1/*N*) is associated with each observation. This will arise naturally in later sections where observations receive weights in the IRLS algorithm. In this case the update step (5) becomes only slightly more complicated:

$${\tilde{\beta}}_{j}\leftarrow \frac{S\phantom{\rule{thinmathspace}{0ex}}\left({\displaystyle {\sum}_{i=1}^{N}{w}_{i}{x}_{\mathit{\text{ij}}}\phantom{\rule{thinmathspace}{0ex}}({y}_{i}-{\tilde{y}}_{i}^{(j)}),\phantom{\rule{thinmathspace}{0ex}}\lambda \alpha )}\right)}{{\displaystyle {\sum}_{i=1}^{N}{w}_{i}{x}_{\mathit{\text{ij}}}^{2}\phantom{\rule{thinmathspace}{0ex}}+\phantom{\rule{thinmathspace}{0ex}}\lambda (1-\alpha )}}.$$

(10)

If the *x*_{j} are not standardized, there is a similar sum-of-squares term in the denominator (even without weights). The presence of weights does not change the computational costs of either algorithm much, as long as the weights remain fixed.

We compute the solutions for a decreasing sequence of values for λ, starting at the smallest value λ_{max} for which the entire vector = 0. Apart from giving us a path of solutions, this scheme exploits *warm starts*, and leads to a more stable algorithm. We have examples where it is faster to compute the path down to λ (for small λ) than the solution only at that value for λ.

When = 0, we see from (5) that _{j} will stay zero if $\frac{1}{N}\left|\langle {x}_{j},y\rangle \right|<\lambda \alpha .$ Hence *N*αλ_{max} = max_{} |*x*_{}, *y*|. Our strategy is to select a minimum value λ_{min} = ελ_{max}, and construct a sequence of *K* values of λ decreasing from λ_{max} to λ_{min} on the log scale. Typical values are ε = 0.001 and *K* = 100.

Irrespective of whether the variables are standardized to have variance 1, we always center each predictor variable. Since the intercept is not regularized, this means that _{0} = , the mean of the *y*_{i}, for all values of α and λ.

It is easy to allow different penalties λ_{j} for each of the variables. We implement this via a penalty scaling parameter γ_{j} ≥ 0. If γ_{j} > 0, then the penalty applied to β_{j} is λ_{j} = λγ_{j}. If γ_{j} = 0, that variable does not get penalized, and always enters the model unrestricted at the first step and remains in the model. Penalty rescaling would also allow, for example, our software to be used to implement the *adaptive lasso* [Zou, 2006].

Considerable speedup is obtained by organizing the iterations around the *active set* of features—those with nonzero coefficients. After a complete cycle through all the variables, we iterate on only the active set till convergence. If another complete cycle does not change the active set, we are done, otherwise the process is repeated. Active-set convergence is also mentioned in Meier et al. [2008] and Krishnapuram and Hartemink [2005].

When the response variable is binary, the linear logistic regression model is often used. Denote by *G* the response variable, taking values in = {1, 2} (the labeling of the elements is arbitrary). The logistic regression model represents the class-conditional probabilities through a linear function of the predictors

$$\begin{array}{cc}\text{Pr}\phantom{\rule{thinmathspace}{0ex}}(G=1|x)\hfill & =\frac{1}{1+{e}^{-({\beta}_{0}+{x}^{T}\beta )}},\hfill \\ \text{Pr}\phantom{\rule{thinmathspace}{0ex}}(G=2|x)\hfill & =\frac{1}{1+{e}^{+({\beta}_{0}+{x}^{T}\beta )}}\hfill \\ \hfill & =1-\text{Pr}\phantom{\rule{thinmathspace}{0ex}}(G=1|x).\hfill \end{array}$$

(11)

Alternatively, this implies that

$$\text{log}\phantom{\rule{thinmathspace}{0ex}}\frac{\text{Pr}\phantom{\rule{thinmathspace}{0ex}}(G\phantom{\rule{thinmathspace}{0ex}}=\phantom{\rule{thinmathspace}{0ex}}1|x)}{\text{Pr}\phantom{\rule{thinmathspace}{0ex}}(G\phantom{\rule{thinmathspace}{0ex}}=\phantom{\rule{thinmathspace}{0ex}}2|x)}={\beta}_{0}+{x}^{T}\beta .$$

(12)

Here we fit this model by regularized maximum (binomial) likelihood. Let *p*(*x*_{i}) = Pr(*G* = 1|*x*_{i}) be the probability (11) for observation *i* at a particular value for the parameters (β_{0}, β), then we maximize the penalized log likelihood

$$\underset{({\beta}_{0},\beta )\in {\mathbb{R}}^{p+1}}{\text{max}\phantom{\rule{thinmathspace}{0ex}}}\left[\frac{1}{N}{\displaystyle \sum _{i=1}^{N}\left\{I\phantom{\rule{thinmathspace}{0ex}}({g}_{i}=1)\phantom{\rule{thinmathspace}{0ex}}\text{log}\phantom{\rule{thinmathspace}{0ex}}p({x}_{i})+I\phantom{\rule{thinmathspace}{0ex}}({g}_{i}=2)\phantom{\rule{thinmathspace}{0ex}}\text{log}\phantom{\rule{thinmathspace}{0ex}}(1-p({x}_{i}))\right\}-\lambda {P}_{\alpha}(\beta )}\right].$$

(13)

Denoting *y*_{i} = *I*(*g*_{i} = 1), the log-likelihood part of (13) can be written in the more explicit form

$$\ell ({\beta}_{0},\beta )=\frac{1}{N}{\displaystyle \sum _{i=1}^{N}{y}_{i}\xb7({\beta}_{0}+{x}_{i}^{T}\beta )-\phantom{\rule{thinmathspace}{0ex}}\text{log}\phantom{\rule{thinmathspace}{0ex}}(1+{e}^{({\beta}_{0}+{x}_{i}^{T}\beta )}),}$$

(14)

a concave function of the parameters. The Newton algorithm for maximizing the (unpenalized) log-likelihood (14) amounts to iteratively reweighted least squares. Hence if the current estimates of the parameters are (_{0}, ), we form a quadratic approximation to the log-likelihood (Taylor expansion about current estimates), which is

$${\ell}_{Q}\phantom{\rule{thinmathspace}{0ex}}({\beta}_{0},\beta )=-\frac{1}{2N}{\displaystyle \sum _{i=1}^{N}{w}_{i}{({z}_{i}-{\beta}_{0}-{x}_{i}^{T}\beta )}^{2}+C\phantom{\rule{thinmathspace}{0ex}}{({\tilde{\beta}}_{0},\tilde{\beta})}^{2}}$$

(15)

where

$${z}_{i}={\tilde{\beta}}_{0}+{x}_{i}^{T}\tilde{\beta}+\frac{{y}_{i}-\tilde{p}({x}_{i})}{\tilde{p}({x}_{i})\phantom{\rule{thinmathspace}{0ex}}(1-\tilde{p}({x}_{i}))},\text{}(\text{working response})$$

(16)

$${w}_{i}=\tilde{p}({x}_{i})\phantom{\rule{thinmathspace}{0ex}}(1-\tilde{p}({x}_{i})),\phantom{\rule{thinmathspace}{0ex}}(\text{weights})$$

(17)

and (*x*_{i}) is evaluated at the current parameters. The last term is constant. The Newton update is obtained by minimizing _{Q}.

Our approach is similar. For each value of λ, we create an outer loop which computes the quadratic approximation _{Q} about the current parameters (_{0}, ). Then we use coordinate descent to solve the penalized weighted least-squares problem

$$\underset{({\beta}_{0},\beta )\in {\mathbb{R}}^{p+1}}{\text{min}}\left\{-{\ell}_{Q}\phantom{\rule{thinmathspace}{0ex}}({\beta}_{0},\beta )+\lambda {P}_{\alpha}(\beta )\right\}.$$

(18)

This amounts to a sequence of nested loops:

- OUTER LOOP: Decrement λ.
- MIDDLE LOOP: Update the quadratic approximation
_{Q}using the current parameters (_{0}, ). - INNER LOOP: Run the coordinate descent algorithm on the penalized weighted-least-squares problem (18).

There are several important details in the implementation of this algorithm.

- When
*p**N*, one cannot run λ all the way to zero, because the saturated logistic regression fit is undefined (parameters wander off to ±∞ in order to achieve probabilities of 0 or 1). Hence the default λ sequence runs down to λ_{min}= ελ_{max}> 0. - Care is taken to avoid coefficients diverging in order to achieve fitted probabilities of 0 or 1. When a probability is within ε = 10
^{−5}of 1, we set it to 1, and set the weights to ε. 0 is treated similarly. - Our code has an option to approximate the Hessian terms by an exact upper-bound. This is obtained by setting the
*w*_{i}in (17) all equal to 0.25 [Krishnapuram and Hartemink, 2005]. - We allow the response data to be supplied in the form of a two-column matrix of counts, sometimes referred to as
*grouped*data. We discuss this in more detail in Section 4.2. - The Newton algorithm is not guaranteed to converge without step-size optimization [in Lee et al., 2006]. Our code does not implement any checks for divergence; this would slow it down, and when used as recommended we do not feel it is necessary.. We have a closed form expression for the starting solutions, and each subsequent solution is warm-started from the previous close-by solution, which generally makes the quadratic approximations very accurate. We have not encountered any divergence problems so far.

When the categorical response variable *G* has *K* > 2 levels, the linear logistic regression model can be generalized to a multi-logit model. The traditional approach is to extend (12) to *K* − 1 logits

$$\text{log}\frac{\text{Pr}(G\phantom{\rule{thinmathspace}{0ex}}=\phantom{\rule{thinmathspace}{0ex}}\ell |x)}{\text{Pr}(\phantom{\rule{thinmathspace}{0ex}}G\phantom{\rule{thinmathspace}{0ex}}=K|x)}={\beta}_{0\ell}+{x}^{T}{\beta}_{\ell},\ell =1,\dots ,K-1.$$

(19)

Here β_{} is a *p*-vector of coefficients. As in Zhu and Hastie [2004], here we choose a more symmetric approach. We model

$$\text{Pr}(G\phantom{\rule{thinmathspace}{0ex}}=\phantom{\rule{thinmathspace}{0ex}}\ell |x)=\frac{{e}^{{\beta}_{0\ell}+{x}^{T}{\beta}_{\ell}}}{{\displaystyle {\sum}_{k=1}^{K}{e}^{{\beta}_{0k}+{x}^{T}{\beta}_{k}}}}$$

(20)

This parametrization is not estimable without constraints, because for any values for the parameters ${\{{\beta}_{0\ell},{\beta}_{\ell}\}}_{1}^{K},{\{{\beta}_{0\ell}-{c}_{0},{\beta}_{\ell}-c\}}_{1}^{K}$ give identical probabilities (20). Regularization deals with this ambiguity in a natural way; see Section 4.1 below.

We fit the model (20) by regularized maximum (multinomial) likelihood. Using a similar notation as before, let *p _{}*(

$$\underset{{\{{\beta}_{0\ell ,}{\beta}_{\ell}\}}_{1}^{K}\in {\mathbb{R}}^{K(p+1)}}{\text{max}}\phantom{\rule{thinmathspace}{0ex}}\left[\frac{1}{N}{\displaystyle \sum _{i=1}^{N}\text{log}\phantom{\rule{thinmathspace}{0ex}}{p}_{{g}_{i}}({x}_{i})-\lambda {\displaystyle \sum _{\ell =1}^{K}{P}_{\alpha}({\beta}_{\ell})}}\right]\phantom{\rule{thinmathspace}{0ex}}.$$

(21)

Denote by **Y** the *N* × *K* *indicator* response matrix, with elements *y*_{i} = *I* (*g*_{i} = ). Then we can write the log-likelihood part of (21) in the more explicit form

$$\ell ({\{{\beta}_{0\ell ,}{\beta}_{\ell}\}}_{1}^{K})=\frac{1}{N}{\displaystyle \sum _{i=1}^{N}\left[{\displaystyle \sum _{\ell =1}^{K}{y}_{i\ell}({\beta}_{0\ell}+{x}_{i}^{T}{\beta}_{\ell})-\text{log}\phantom{\rule{thinmathspace}{0ex}}\left({\displaystyle \sum _{\ell =1}^{K}{e}^{{\beta}_{0\ell}+{x}_{i}^{T}{\beta}_{\ell}}}\right)}\right]\phantom{\rule{thinmathspace}{0ex}}}.$$

(22)

The Newton algorithm for multinomial regression can be tedious, because of the vector nature of the response observations. Instead of weights *w*_{i} as in (17), we get weight *matrices*, for example. However, in the spirit of coordinate descent, we can avoid these complexities. We perform *partial Newton steps* by forming a partial quadratic approximation to the log-likelihood (22), allowing only (β_{0}, β_{}) to vary for a single class at a time. It is not hard to show that this is

$${\ell}_{Q\ell}({\beta}_{0\ell ,}{\beta}_{\ell})=-\frac{1}{2N}{\displaystyle \sum _{i=1}^{N}{w}_{i\ell}{({z}_{i\ell}-{\beta}_{0\ell}-{x}_{i}^{T}{\beta}_{\ell})}^{2}+C\phantom{\rule{thinmathspace}{0ex}}({\{{\tilde{\beta}}_{0k},{\tilde{\beta}}_{k}\}}_{1}^{K})},$$

(23)

where as before

$${z}_{i\ell}={\tilde{\beta}}_{0\ell}+{x}_{i}^{T}{\tilde{\beta}}_{\ell}+\frac{{y}_{i\ell}-{\tilde{p}}_{\ell}({x}_{i})}{{\tilde{p}}_{\ell}({x}_{i})\phantom{\rule{thinmathspace}{0ex}}(1-{\tilde{p}}_{\ell}({x}_{i}))},$$

(24)

$${w}_{i\ell}={\tilde{p}}_{\ell}({x}_{i})\phantom{\rule{thinmathspace}{0ex}}(1-{\tilde{p}}_{\ell}({x}_{i})),$$

(25)

Our approach is similar to the two-class case, except now we have to cycle over the classes as well in the outer loop. For each value of λ, we create an outer loop which cycles over and computes the partial quadratic approximation _{Q} about the current parameters (_{0}, ). Then we use coordinate descent to solve the penalized weighted least-squares problem

$$\underset{({\beta}_{0\ell ,}{\beta}_{\ell})\in {\mathbb{R}}^{p+1}}{\text{min}}\left\{-{\ell}_{Q\ell}({\beta}_{0\ell},{\beta}_{\ell})+\lambda {P}_{\alpha}\phantom{\rule{thinmathspace}{0ex}}({\beta}_{\ell})\right\}.$$

(26)

This amounts to the sequence of nested loops:

- OUTER LOOP: Decrement λ.
- MIDDLE LOOP (OUTER): Cycle over {1, 2, …,
*K*, 1, 2, …}. - MIDDLE LOOP (INNER): Update the quadratic approximation
_{Q}using the current parameters ${\{{\tilde{\beta}}_{0k},{\tilde{\beta}}_{k}\}}_{1}^{K}.$ - INNER LOOP: Run the co-ordinate descent algorithm on the penalized weighted-least-squares problem (26).

As was pointed out earlier, if ${\{{\beta}_{0\ell},{\beta}_{\ell}\}}_{1}^{K}$ characterizes a fitted model for (20), then ${\{{\beta}_{0\ell}-{c}_{0},{\beta}_{\ell}-c\}}_{1}^{K}$ gives an identical fit (*c* is a *p*-vector). Although this means that the log-likelihood part of ((21) is insensitive to (*c*_{0}, *c*), the penalty is not. In particular, we can always improve an estimate ${\{{\beta}_{0\ell},{\beta}_{\ell}\}}_{1}^{K}$
(w.r.t. (21)) by solving

$$\underset{c\in {\mathbb{R}}^{p}\phantom{\rule{thinmathspace}{0ex}}}{\text{min}}{\displaystyle \sum _{\ell =1}^{K}{P}_{\alpha}\phantom{\rule{thinmathspace}{0ex}}({\beta}_{\ell}-c).}$$

(27)

This can be done separately for each coordinate, hence

$${c}_{j}=\text{arg}\phantom{\rule{thinmathspace}{0ex}}\underset{t}{\text{min}}{\displaystyle \sum _{\ell =1}^{K}\left[\frac{1}{2}(1-\alpha )\phantom{\rule{thinmathspace}{0ex}}{({\beta}_{j\ell}-t)}^{2}+\alpha |{\beta}_{j\ell}-t|\right]}.$$

(28)

**Theorem 1** *Consider problem (28) for values* α [0, 1]. *Let* _{j} *be the mean of the* β_{j}, and${\beta}_{j}^{M}$ *a median of the* β_{j} (*and for simplicity assume*${\overline{\beta}}_{j}\le {\beta}_{j}^{M}.$ *Then we have*

$${c}_{j}\in [{\overline{\beta}}_{j},{\beta}_{j}^{M}],$$

(29)

*with the left endpoint achieved if* α = 0, *and the right if* α = 1.

The two endpoints are obvious. The proof of Theorem 1 is given in the appendix. A consequence of the theorem is that a very simple search algorithm can be used to solve (28). The objective is piecewise quadratic, with knots defined by the β_{j}. We need only evaluate solutions in the intervals including the mean and median, and those in between.

We *recenter* the parameters in each index set *j* after each INNER MIDDLE LOOP step, using the the solution *c _{j}* for each

Not all the parameters in our model are regularized. The intercepts β_{0} are not, and with our penalty modifiers γ_{j} (section 2.6) others need not be as well. For these parameters we use mean centering.

As in the two class case, the data can be presented in the form of a *N* × *K* matrix *m*_{i} of non-negative numbers. For example, if the data are grouped: at each *x*_{i} we have a number of multinomial samples, with *m*_{i} falling into category . In this case we divide each row by the row-sum *m*_{i} = ∑_{} *m*_{i}, and produce our response matrix *y*_{i} = *m*_{i}/*m*_{i}. *m*_{i} becomes an observation weight. Our penalized maximum likelihood algorithm changes in a trivial way. The working response (24) is defined exactly the same way (using *y*_{i} just defined). The weights in (25) get augmented with the observation weight *m*_{i}:

$${w}_{i\ell}={m}_{i}{\tilde{p}}_{\ell}({x}_{i})\phantom{\rule{thinmathspace}{0ex}}(1-{\tilde{p}}_{\ell}({x}_{i})).$$

(30)

Equivalently, the data can be presented directly as a matrix of class proportions, along with a weight vector. From the point of view of the algorithm, any matrix of positive numbers and any non-negative weight vector will be treated in the same way.

In this section we compare the run times of the coordinate-wise algorithm to some competing algorithms. These use the lasso penalty (α = 1) in both the regression and logistic regression settings. All timings were carried out on an Intel Xeon 2.80GH processor.

We do not perform comparisons on the elastic net versions of the penalties, since there is not much software available for elastic net. Comparisons of our glmnet code with the R package elasticnet will mimic the comparisons with lars for the lasso, since elasticnet is built on the lars package.

We generated Gaussian data with *N* observations and *p* predictors, with each pair of predictors *X _{j}*,

$$Y={\displaystyle \sum _{j=1}^{p}{X}_{j}{\beta}_{j}+k\xb7Z}$$

(31)

where β_{j} = (−1)^{j} exp(−2(*j* − 1)/20), *Z* ~ *N* (0, 1) and *k* is chosen so that the signal-to-noise ratio is 3.0. The coefficients are constructed to have alternating signs and to be exponentially decreasing.

Table 1 shows the average CPU timings for the coordinate-wise algorithm, and the LARS procedure [Efron et al., 2004]. All algorithms are implemented as R language functions. The coordinate-wise algorithm does all of its numerical work in Fortran, while LARS (written by Efron and Hastie) does much of its work in R, calling Fortran routines for some matrix operations. However comparisons in [Friedman et al., 2007] showed that LARS was actually faster than a version coded entirely in Fortran. Comparisons between different programs are always tricky: in particular the LARS procedure computes the entire path of solutions, while the coordinate-wise procedure solves the problem for a set of pre-defined points along the solution path. In the orthogonal case, LARS takes min(*N*, *p*) steps: hence to make things roughly comparable, we called the latter two algorithms to solve a total of min(*N*, *p*) problems along the path. Table 1 shows timings in seconds averaged over three runs. We see that glmnet is considerably faster than LARS; the covariance-updating version of the algorithm is a little faster than the naive version when *N* > *p* and a little slower when *p* > *N*. We had expected that high correlation between the features would increase the run time of glmnet, but this does not seem to be the case.

We used the same simulation setup as above, except that we took the continuous outcome *y*, defined *p* = 1/(1 + exp(−*y*)) and used this to generate a two-class outcome *z* with Prob(*z* = 1) = *p*, Prob(*z* = 0) = 1 − *p*. We compared the speed of glmnet to the interior point method l1lognet proposed by Koh et al. [2007], Bayesian Logistic Regression (BBR) due to Genkin et al. [2007] and the Lasso Penalized Logistic (LPL) program supplied by Ken Lange [Wu and Lange, 2008b]. The latter two methods also use a coordinate descent approach.

The BBR software automatically performs ten-fold cross-validation when given a set of λ values. Hence we report the total time for ten-fold cross-validation for all methods using the same 100 λ values for all. Table 2 shows the results; in some cases, we omitted a method when it was seen to be very slow at smaller values for *N* or *p*.

Timings (seconds) for logistic models with lasso penalty. Total time for tenfold cross-validation over a grid of 100 λ values.

Again we see that glmnet is the clear winner: it slows down a little under high correlation. The computation seems to be roughly linear in *N*, but grows faster than linear in *p*.

Table 3 shows some results when the feature matrix is sparse: we randomly set 95% of the feature values to zero. Again, the glmnet procedure is significantly faster than l1lognet.

Table 4 shows some timing results for four different datasets.

- Cancer [Ramaswamy et al., 2001]: gene-expression data with 14 cancer classes.
- Leukemia [Golub et al., 1999a]: gene-expression data with a binary response indicating type of leukemia—
*AML*vs*ALL*. We used the preprocessed data of Dettling [2004]. - Internet-Ad [Kushmerick, 1999]: document classification problem with mostly binary features. The response is binary, and indicates whether the document is an advertisement. Only 1.2% nonzero values in the predictor matrix.
- Newsgroup [Lang, 1995]: document classification problem. We used the training set cultured from these data by Koh et al. [2007]. The response is binary, and indicates a subclass of topics; the predictors are binary, and indicate the presence of particular tri-gram sequences. The predictor matrix has 0.05% nonzero values.

Timings (seconds, unless stated otherwise) for some real datasets. For the Cancer, Leukemia and Internet-Ad datasets, times are for ten-fold cross-validation over 100 λ values; for Newsgroup we performed a single run with 100 values of λ, **...**

All four datasets are available as saved R data objects at http://www-stat.stanford.edu/~hastie/glmnet/ (the latter two in sparse format using the Matrix package).

For the Leukemia and Internet-Ad datasets, the BBR program used fewer than 100 λ values so we estimated the total time by scaling up the time for smaller number of values. The Internet-Ad and Newsgroup datasets are both sparse: 1% nonzero values for the former, 0.06% for the latter. Again glmnet is considerably faster than the competing methods.

Cyclical coordinate descent methods are a natural approach for solving convex problems with _{1} or _{2} constraints, or mixtures of the two (elastic net). Each coordinate-descent step is fast, with an explicit formula for each coordinate-wise minimization. The method also exploits the sparsity of the model, spending much of its time evaluating only inner products for variables with non-zero coefficients. Its computational speed both for large *N* and *p* are quite remarkable.

A public domain R language package glmnet is available from the CRAN website. Matlab functions (written by Rahul Mazumder), as well as the real datasets used in Section 5.3, can be downloaded from the second author’s website at http://www-stat.stanford.edu/~hastie/glmnet/

We would like to thank Holger Hoefling for helpful discussions, and Rahul Mazumder for writing the Matlab interface to our Fortran routines. We thank the associate editor and two referees who gave useful comments on an earlier draft of this article.

Friedman was partially supported by grant DMS-97-64431 from the National Science Foundation. Hastie was partially supported by grant DMS-0505676 from the National Science Foundation, and grant 2R01 CA 72028-07 from the National Institutes of Health. Tibshirani was partially supported by National Science Foundation Grant DMS-9971405 and National Institutes of Health Contract N01-HV-28183.

*Proof of theorem 1*. We have

$${c}_{j}=\text{arg}\phantom{\rule{thinmathspace}{0ex}}\underset{t}{\text{min}}{\displaystyle \sum _{\ell =1}^{K}\left[\frac{1}{2}(1-\alpha )\phantom{\rule{thinmathspace}{0ex}}{({\beta}_{j\ell}-t)}^{2}+\alpha |{\beta}_{j\ell}-t|\right]\phantom{\rule{thinmathspace}{0ex}}}.$$

(32)

Suppose α (0, 1). Differentiating w.r.t. *t* (using a sub-gradient representation), we have

$$\sum _{\ell =1}^{K}[-(1-\alpha )\phantom{\rule{thinmathspace}{0ex}}({\beta}_{j\ell}-t)-\alpha {s}_{j\ell}]}=0$$

(33)

where *s*_{j} = sign(β_{j} − *t*) if β_{j} ≠ *t* and *s*_{j} [−1, 1] otherwise. This gives

$$t={\overline{\beta}}_{j}+\frac{1}{K}\frac{\alpha}{1-\alpha}{\displaystyle \sum _{\ell =1}^{K}{s}_{j\ell}}$$

(34)

It follows that *t* cannot be larger than ${\beta}_{j}^{M}$ since then the second term above would be negative and this would imply that *t* is less than _{j}. Similarly *t* cannot be less than _{j}, since then the second term above would have to be negative, implying that *t* is larger than ${\beta}_{j}^{M}$

- Candes E, Tao T. The Dantzig selector: statistical estimation when p is much larger than n. Annals of Statistics. 2007;35(6):2313–2351.
- Chen SS, Donoho D, Saunders M. Atomic decomposition by basis pursuit. SIAM Journal on Scientific Computing. 1998;20(1):33–61.
- Daubechies I, Defrise M, De Mol C. An iterative thresholding algorithm for linear inverse problems with a sparsity constraint. Communications on Pure and Applied Mathematics. 2004;57:1413–1457.
- Dettling M. Bagboosting for tumor classification with gene expression data. Bioinformatics. 2004:3583–3593. [PubMed]
- Donoho DL, Johnstone IM. Ideal spatial adaptation by wavelet shrinkage. Biometrika. 1994;81:425–455.
- Efron B, Hastie T, Johnstone I, Tibshirani R. Least angle regression. Annals of Statistics. 2004;32(2):407–499. (with discussion)
- Friedman J, Hastie T, Hoefling H, Tibshirani R. Pathwise coordinate optimization. Annals of Applied Statistics. 2007;2(1):302–332.
- Friedman J, Hastie T, Tibshirani R. Sparse inverse covariance estimation with the graphical lasso. Biostatistics. 2008;9:432–441. [PMC free article] [PubMed]
- Fu W. Penalized regressions: the bridge vs. the lasso. Journal of Computational and Graphical Statistics. 1998;7(3):397–416.
- Genkin A, Lewis D, Madigan D. Large-scale bayesian logistic regression for text categorization. Technometrics. 2007;49(3):291–304.
- Golub T, Slonim D, Tamayo P, Huard C, Gaasenbeek M, Mesirov J, Coller H, Loh M, Downing J, Caligiuri M, Bloomfield C, Lander E. Molecular classification of cancer: class discovery and class prediction by gene expression monitoring. Science. 1999a;286:531–536. [PubMed]
- Golub T, Slonim DK, Tamayo P, Huard C, Gaasenbeek M, Mesirov JP, Coller H, Loh ML, Downing JR, Caligiuri MA, Bloomfield CD, Lander ES. Molecular classification of cancer: class discovery and class prediction by gene expression monitoring. Science. 1999b;286:531–536. [PubMed]
- Hastie T, Rosset S, Tibshirani R, Zhu J. The entire regularization path for the support vector machine. Journal of Machine Learning Research. 2004;(5):1391–1415.
- in Lee S, Lee H, Abneel P, Ng A. Efficient l1 logistic regression; Proceedings of the Twenty-First National Conference on Artificial Intelligence (AAAI-06); 2006.
- Koh K, Kim S-J, Boyd S. An interior-point method for large-scale l1-regularized logistic regression. Journal of Machine Learning Research. 2007;8:1519–1555.
- Krishnapuram B, Hartemink AJ. Sparse multinomial logistic regression: Fast algorithms and generalization bounds; IEEE Trans. Pattern Anal. Mach. Intell; 2005. pp. 957–968. ISSN 0162-8828. doi: http://dx.doi.org/10.1109/TPAMI.2005.127. Fellow-Lawrence Carin and Senior Member-Mario A. T. Figueiredo. [PubMed]
- Kushmerick N. Learning to remove internet advertisements; Proceedings of AGENTS-99; 1999.
- Lang K. Newsweeder: Learning to filter netnews; Proceedings of the Twenty-First International Conference on Machine Learning (ICML); 1995. pp. 331–339.
- Meier L, van de Geer S, Bühlman P. The group lasso for logistic regression. Journal of the Royal Statistical Society B. 2008 February;70(1):53–71.
- Osborne M, Presnell B, Turlach B. A new approach to variable selection in least squares problems. IMA Journal of Numerical Analysis. 2000;20:389–404.
- Park MY, Hastie T.
*l*_{1}-regularization path algorithm for generalized linear models. Journal of the Royal Statistical Society Series B. 2007;69:659–677. - Ramaswamy S, Tamayo P, Rifkin R, Mukherjee S, Yeang C, Angelo M, Ladd C, Reich M, Latulippe E, Mesirov J, Poggio T, Gerald W, Loda M, Lander E, Golub T. Multiclass cancer diagnosis using tumor gene expression signature. PNAS. 2001;98:15149–15154. [PubMed]
- Rosset S, Zhu J. Adaptable, efficient and robust methods for regression and classification via piecewise linear regularized coefficient paths. 2007 Unpublished.
- Shevade K, Keerthi S. A simple and efficient algorithm for gene selection using sparse logistic regression. Bioinformatics. 2003;19:2246–2253. [PubMed]
- Tibshirani R. Regression shrinkage and selection via the lasso. Journal of the Royal Statistical Society, Series B. 1996;58:267–288.
- Tibshirani R. The lasso method for variable selection in the cox model. Statistics in Medicine. 1997;16:385–395. [PubMed]
- Tseng P. Convergence of block coordinate descent method for nondifferentiable maximization. J. Opt. Theory and Applications. 2001;109(3):474–494.
- Van der Kooij A. Technical report. Leiden University: Dept. of Data Theory; 2007. Prediction accuracy and stability of regrsssion with optimal sclaing transformations.
- Wu T, Lange K. Coordinate descent algorithms for lasso penalized regression. Annals of Applied Statistics. 2008a;2(1):224–244.
- Wu T, Lange K. Coordinate descent procedures for lasso penalized regression. Annals of Applied Statistics. 2008b;2(1):224–244.
- Wu T, Chen Y, Hastie T, Sobel E, Lange K. Genome-wide association analysis by penalized logistic regression. Bioinformatics. 2009 March;25(6):714–721. [PMC free article] [PubMed]
- Yuan M, Lin Y. Model selection and estimation in regression with grouped variables. Journal of the Royal Statistical Society, Series B. 2007;68(1):49–67.
- Zhu J, Hastie T. Classification of gene microarrays by penalized logistic regression. Biostatistics. 2004 (to appear) [PubMed]
- Zou H. The adaptive lasso and its oracle properties. Journal of the American Statistical Association. 2006;101:1418–1429.
- Zou H, Hastie T. Regularization and variable selection via the elastic net. J. Royal. Stat. Soc. B. 2005;67(2):301–320.

PubMed Central Canada is a service of the Canadian Institutes of Health Research (CIHR) working in partnership with the National Research Council's national science library in cooperation with the National Center for Biotechnology Information at the U.S. National Library of Medicine(NCBI/NLM). It includes content provided to the PubMed Central International archive by participating publishers. |