\[ \Lambda(X\beta) - \beta'(X'Y) = - \log L(\beta|Y) = \ell(\beta|Y). \]
\[ \Lambda(\alpha) = \sum_{i=1}^n \Lambda(\alpha_i) \]
and \(\Lambda\) is the log MGF of \(Y\)’s as a function of the natural parameter.
\[ \Lambda(X\beta) - \beta'(X'Y) + {\cal P}(\beta) \]
Three examples we’ve seen:
Gaussian \(\Lambda(\alpha) = \alpha^2/2\) (or scale objective \(\sigma^2\));
Logistic \(\Lambda(\alpha) = \log(1 + e^{\alpha})\).
Poisson log-linear \(\Lambda(\alpha) = e^{\alpha}\).
\[ {\cal P}(\beta) = \frac{\lambda}{2} \|\beta\|_2^2 = \frac{\lambda}{2} \sum_{j=1}^p \beta_j^2. \]
\[ \hat{\beta}_{\lambda} = \text{argmin}_{\beta} \Lambda(X\beta) -\beta'(X'Y) + \frac{\lambda}{2} \|\beta\|^2_2 \]
\[ -(X\beta)'Y + \Lambda(X\beta) + \frac{\lambda}{2} \|\beta\|^2_2 \]
\[ {\cal P}(\beta) = \frac{1}{2} \sum_{j=1}^p \lambda_j \beta_j^2 \]
unpenalized variables have \(\lambda_j=0\).
\[ {\cal P}(\beta) = \frac{1}{2}\beta'Q\beta \]
\[ \beta \mapsto \Lambda(X\beta) - \beta'(X'Y) + {\cal P}(\beta) = \ell(\beta) + \frac{1}{2} \beta'Q\beta \]
From unpenalized case we know 2nd Taylor approximation of likelihood.
Differentiating the penalty:
\[ \begin{aligned} \nabla {\cal P}(\beta) &= Q \beta \\ \nabla^2 {\cal P}(\beta) &= Q \end{aligned} \]
\[ \hat{\beta}^{(t)} = \hat{\beta}^{(t-1)} - (X'W^{(t-1)}X + Q)^{-1} \left(X'(E_{\hat{\beta}^{(t-1)}}(Y) - Y) + Q \hat{\beta}^{(t-1)}\right) \]
\[ \hat{\beta}^{(t)} = \hat{\beta}^{(t-1)} - (X'W^{(t-1)}X + Q)^{-1} \left(X'W^{(t-1)}g'(\hat{\mu}^{(t-1)})(\hat{\mu}^{(t-1)} - Y) + Q \hat{\beta}^{(t-1)}\right) \]
\[ \hat{\beta} = (X'X+\lambda I)^{-1}X'Y \sim N\left((X'X+\lambda I)^{-1}X'X\beta, \sigma^2 (X'X+\lambda I)^{-1}X'X(X'X+\lambda I)^{-1}\right) \]
\[ \begin{aligned} (X'X+\lambda I)^{-1}X'X &= \sum_{i=1}^p \frac{d^2_i}{d^2_i+\lambda} V_iV_i' \\ (X'X+\lambda I)^{-1}X'X(X'X+\lambda I)^{-1} &= \sum_{i=1}^p \frac{d^2_i}{(d^2_i+\lambda)^2} V_iV_i' \\ \end{aligned} \]
\[ \|E[\hat{\beta}]-\beta\|^2_2 = \lambda^2 \sum_{i=1}^p \frac{\alpha_i^2}{(d_i^2 + \lambda)^2} \\ \]
\[ \text{Tr}(\text{Var}(\hat{\beta})) = \sum_{i=1}^p \frac{d^2_i}{(d^2_i+\lambda)^2} \leq \sum_{i=1}^p \frac{1}{d_i^2} \]
RHS is trace of \(\text{Var}((X'X)^{-1}(X'Y))\).
Ridge always has smaller variance.
\[ MSE(\hat{\beta}) = E[\|\hat{\beta}-\beta\|^2_2] = \|E[\hat{\beta}]-\beta\|^2_2 + \text{Tr}(\text{Var}(\hat{\beta})) \]
\[\frac{d}{d\lambda}\left(\|E[\hat{\beta}]-\beta\|^2_2 + \text{Tr}(\text{Var}(\hat{\beta}))\right)\biggl|_{\lambda=0} < 0 \]
## Loading required package: Matrix
## Loaded glmnet 4.0-2
library(ElemStatLearn)
data(spam)
X_spam = scale(model.matrix(glm(spam ~ .,
family=binomial,
data=spam))[,-1]) # drop intercept## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
Y_spam = spam$spam == 'spam'
G_spam = glmnet(X_spam,
Y_spam,
alpha=0, # this makes it ridge
family='binomial')
plot(G_spam)data(SAheart)
X_heart = scale(model.matrix(glm(chd ~ ., family=binomial, data=SAheart))[,-1]) # drop intercept
Y_heart = SAheart$chd
G_heart = glmnet(X_heart,
Y_heart,
alpha=0,
family='binomial')
plot(G_heart)\[ {\cal P}(\beta) = \lambda \|\beta\|_1 = \sum_{j=1}^p \lambda_j |\beta_j|. \]
There are several sparsity inducing penalties out there: SCAD, MCP, etc.
But we know less about the “solutions” compared to LASSO because LASSO is a convex problem.
Solvable even in very high dimensions. (“same” for SCAD, MCP, etc.)
KKT conditions give an exact description of the solution however we decide to solve it (not same for SCAD, MCP, etc), at least under uniqueness.
In broad generality, yes. Uniqueness of the LASSO.
Many algorithms out there. Many of you will end up taking EE364 (Convex Optimization) where you’ll see things like this in more detail.
We’ll consider two simple algorithms: coordinate descent, proximal gradient descent.
Everyone has their own way of talking about LASSO. These notes are just my way.
If the penalty \({\cal P}\) were smooth, then we could use something like Newton-Raphson as we did for fitting the GLM.
The penalty is differentiable everywhere except points where one of the \(\beta_j\)’s is 0: \(\implies\) not smooth.
However, the penalty is separable meaning
\[ {\cal P}(\beta) = \sum_{i=1}^p p_i(\beta_i). \]
Block separability allows for a partition of \(\{1,\dots,p\}= \cup_{g \in G} g\) – group LASSO an example of this.
When the penalty is separable, the problem can be solved by successively solving low-dimensional problems.
\[ \hat{\beta}^{(t+1)}_j = \text{argmin}_{\beta_j \in \mathbb{R}} \left[\beta_j \mapsto \Lambda (X_{-j}\hat{\beta}^{(t)}_{-j} + X_j \beta_j) - \beta_j(X_j'Y) + p_j(\beta_j) \right] \]
Suppose we have a prior with independent coordinates with negative log density \({\cal P}(\beta)\).
The Gibbs sampler considers same “objective” that a coordinate descent algorithm does.
Instead of minimizing this function, it draws from a density proportional to its negative exponential.
Each iteration \(t\) chooses a coordinate \(j\) to update. Let the current position be \(\hat{\beta}^t\) draw \(\hat{\beta}^{(t+1)}_j\) from a density proportional to:
\[ \beta_j \mapsto \exp\left(-\left[\Lambda (X_{-j}\hat{\beta}^{(t)}_{-j} + X_j \beta_j) - \beta_j(X_j'Y) + p_j(\beta_j)\right] \right) \]
sampleoptimizeEach minimization is a logistic regression with a single feature \(X_j\) and offset \(X_{-j}\hat{\beta}^{(t)}_{-j}\).
Objective with offset vector \(Z\)
\[ \beta \mapsto -(X\beta + Z)'Y + \sum_{i=1}^n \log(1 + \exp(X_i'\beta + Z_i)) \]
\[ X' \left(Y - \frac{\exp(X\widehat{\beta} + Z)}{1 + \exp(X\widehat{\beta} + Z)} \right) = 0 \]
X_sim = matrix(rnorm(200), 100, 2)
Z_sim = rnorm(100)
Y_sim = rbinom(100, 1, 0.5)
M = glm(Y_sim ~ X_sim - 1, offset=Z_sim, family=binomial);
affine_pred = X_sim %*% coef(M) + Z_sim
pi_hat = exp(affine_pred) / (1 + exp(affine_pred))
t(X_sim) %*% (Y_sim - pi_hat)## [,1]
## [1,] 4.493916e-09
## [2,] -5.790705e-08
\[ \begin{aligned} \lambda &> \left|\frac{\partial}{\partial \beta_j} \left[\Lambda(X_{-j} \widehat{\beta}_{-j} + X_j \beta_j) - \beta_j \cdot (X_j'Y)\right] \biggl|_{\beta_j=0} \right| \\ &= \left| X_j'\left( \pi(\hat{\beta}_{-j}, 0_j) - Y \right) \right| \end{aligned} \]
then \[ 0 = \text{argmin}_{\beta_j \in \mathbb{R}} \left[\beta_j \mapsto \Lambda (X_{-j}\hat{\beta}^{(t)}_{-j} + X_j \beta_j) - \beta_j(X_j'Y) + p_j(\beta_j) \right] \]
library(glmnet)
library(ElemStatLearn)
data(spam)
X_spam = scale(model.matrix(glm(spam ~ .,
family=binomial,
data=spam))[,-1]) # drop intercept## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
beta_CV_spam = coef(G_spam,
s=cvG_spam$lambda.min,
exact=TRUE,
x=X_spam,
y=Y_spam)
sum(beta_CV_spam[-1] != 0) # not very sparse in this case...## [1] 53
XnewX = X_spam[1:30,]
newY_hat = predict(G_spam,
newX,
s=cvG_spam$lambda.min,
type="response",
exact=TRUE,
x=X_spam,
y=Y_spam)
newY_hat[1:5]## [1] 0.5748062 0.9800819 0.9999740 0.7488135 0.7487251
data(SAheart)
X_heart = scale(model.matrix(glm(chd ~ ., family=binomial, data=SAheart))[,-1]) # drop intercept
Y_heart = SAheart$chd
G_heart = glmnet(X_heart, Y_heart, family='binomial')
plot(G_heart)beta_1se_heart = coef(G_heart,
s=cvG_heart$lambda.1se,
exact=TRUE,
x=X_heart,
y=Y_heart)
sum(beta_1se_heart[-1] != 0) # eliminates a few ## [1] 5
Updates all coordinates each step.
This method takes advantage of the fact that
\[ \text{argmin}_{\beta} \frac{L}{2}\|Z-\beta\|^2_2 + {\cal P}(\beta) \]
is soft-thresholding, most importantly it is fast
\[ \hat{\beta}_i = \max(|Z_i| - \lambda_i / L, 0) \cdot \text{sign}(Z_i) \]
\[ Q^L(\beta;\hat{\beta}^{(t)}) = \ell(\hat{\beta}^{(t)}) + \nabla \ell(\hat{\beta}^{(t)})'(\beta - \hat{\beta}^{(t)}) + \frac{L}{2} \|\beta - \hat{\beta}^{(t)}\|^2_2 + {\cal P}(\beta) \]
\[ \hat{\beta}^{(t+1)} = \text{argmin}_{\beta} Q^L(\beta; \hat{\beta}^{(t)}) = \text{argmin}_{\beta} \frac{L}{2} \|\beta - \hat{\beta}^{(t)} + L^{-1} \nabla \ell(\hat{\beta}^{(t)})\|^2_2 + {\cal P}(\beta). \]
Quadratic approximation similar to Newton-Raphson.
If \(L\) is chosen so that \(L \cdot I \geq \nabla^2 \ell(\beta)\) for all \(\beta\) then this is an example of Majorization-Minimization (MM) method.
Stepsize \(L\) only needs to be chosen to be a descent – backtracking typically used.
There are several accelerated proximal gradient descent algorithms out there, some local to us: NESTA, TFOCS.
Proximal algorithm is key ingredient to all of these methods.
\[ \text{minimize}_{\beta} f(\beta) \]
\[ \begin{aligned} Q(\beta;\beta) &= f(\beta) \\ Q(\beta;\beta') & \geq f(\beta) \qquad \forall \beta, \beta' \end{aligned} \]
\[ \hat{\beta}^{(t+1)} = \text{argmin}_{\beta} Q(\beta;\beta^{(t)}) \]
Just as coordinate descent “looks” like Gibbs sampling. There is an analogous MCMC sampler (at least for smooth penalties…)
Langevin sampling
\[ \hat{\beta}^{(t+1)} = \hat{\beta}^{(t)} + \alpha \nabla \left[ \ell(\hat{\beta}^{(t)}) + {\cal P}(\hat{\beta}^{(t)}) \right] + \sqrt{2 \alpha} \cdot \xi^{(t)} \]
with \(\xi^{(t)} \sim N(0,I)\).
\[ Z \mapsto \text{argmin}_{\beta} \frac{1}{2}\|\beta-Z\|^2_2 + {\cal P}(\beta) \]
is called the proximal operator of \({\cal P}\).
Proximal gradient descent methods rely on \({\cal P}\) being fast.
Each step above evaluates the proximal map of \(L^{-1} \cdot {\cal P}\).
Reference: Parikh and Boyd
\[ \text{minimize}_{\beta} \frac{1}{2} \|Y - X\beta\|^2_2 \]
subject to \({\cal P}(\beta) \leq C\).
\[ Z \mapsto \text{argmin}_{\beta:\|\beta\|_1 \leq C} \frac{L}{2} \|\beta-Z\|^2_2. \]
\[ \hat{\beta}^{(t)} - \frac{1}{L} \nabla \ell(\hat{\beta}^{(t)}). \]
onto the convex set \(\left\{\beta: \|\beta\|_1 \leq C \right\}.\)
\[ \text{minimize}_{\beta} \ell(\beta) + {\cal P}(\beta) \ ? \]
\[ \nabla \ell (\hat{\beta}) + \hat{u} = 0 \iff X'Y = X' \nabla \Lambda(X\hat{\beta}) + \hat{u} \]
where
\[ \hat{u} \in \partial {\cal P}(\hat{\beta}). \]
The set \(\partial {\cal P}(\beta)\) is called the subdifferential of \({\cal P}\) at \(\beta\).
If \({\cal P}\) is differentiable at \(\beta\), then the subdifferential is the derivative.
Can also deduce stationarity conditions from proximal gradient algorithm.
\[ \hat{\beta} = S_{\lambda L^{-1}}\left(\hat{\beta} - L^{-1} \nabla \ell(\hat{\beta})\right). \]
\[ |L^{-1}\nabla \ell(\hat{\beta})_i| \leq \lambda L^{-1} \ \implies \ |\nabla \ell(\hat{\beta})_i| \leq \lambda \]
\[ \hat{\beta}_i - L^{-1} \nabla \ell(\hat{\beta})_i = \hat{\beta}_i + \text{sign}(\hat{\beta}_i) \cdot \lambda L^{-1} \ \implies \ -\nabla\ell(\hat{\beta})_i = \lambda \cdot \text{sign}(\hat{\beta}_i) \]
Very briefly, what is the subdifferential for our \({\cal P}\)?
Note that
\[ {\cal P}(\beta) = \sup_{u: |u_i| \leq \lambda_i} u'\beta. \]
\[ {\cal P}(\beta) = \sup_{u \in K} u'\beta, \]
the subdifferential is
\[ u \in \partial {\cal P}(\beta) \iff \beta \in N_u(K) \]
with \(N_u(K)\) the set of normal directions at \(u \in K\).
\[ \left\{u: u'\beta = {\cal P}(\beta) \right\}. \]
Suppose \(\hat{\beta}_{-E}=0, \min_{j \in E}|\hat{\beta}_j|>0\) and \(\text{sign}(\hat{\beta}_E)=s_E\).
Then,
\[ \hat{u} \in \partial{\cal P}(\hat{\beta}) \iff \|u_{-E}/\lambda_{-E}\|_{\infty} \leq 1, u_E = \lambda_E s_E. \]
X = matrix(rnorm(300), 100, 3)
beta = rep(0, 3)
beta[1:2] = 3
Y = X %*% beta + rnorm(100)
G = glmnet(X, Y, standardize=FALSE, intercept=FALSE)
lam = G$lam[10]
lam## [1] 1.322557
## [1] 1.573924 1.736504 0.000000
## [,1]
## [1,] -1.32255694
## [2,] -1.32255695
## [3,] 0.02511821
## [1] 1.322557
## [1] 1.57392444 1.73650397 0.02511821
Let’s perturb \(Y\) a little and see what happens.
Y_star = Y + 0.1 * rnorm(100)
G_star = glmnet(X, Y_star, intercept=FALSE, standardize=FALSE)
beta_star = coef(G_star, s=lam, exact=TRUE, x=X, y=Y_star)[2:4]
beta_star## [1] 1.570243 1.739898 0.000000
## [,1]
## [1,] -1.32255592
## [2,] -1.32255695
## [3,] 0.03358971
## [1] 1.57024314 1.73989803 0.03358971
## [1] 1.57392444 1.73650397 0.02511821
Suppose variables \(E\) are selected with signs \(s_E\).
KKT equations yield
\[ \begin{aligned} \nabla \ell(\hat{\beta})_E &= - \lambda_E s_E \\ \|\nabla \ell(\hat{\beta})_{-E}/\lambda_{-E}\|_{\infty} &\leq 1 \\ \end{aligned} \]
\[ \beta_E \overset{\ell^E}{\mapsto} \ell(\beta_E, 0) \]
\[ \nabla \ell^E(\hat{\beta}_E) = -\lambda_E s_E \]
with constraint \(\text{sign}(\hat{\beta}_E) = s_E\).
\[ \bar{\beta}_E = \hat{\beta}_E + (X_E'X_E)^{-1} \lambda_E s_E \]
or
\[ \hat{\beta}_E = \bar{\beta}_E - (X_E'X_E)^{-1} \lambda_E s_E \]
In the Gaussian case this reads \[ \text{sign}((X_E'X_E)^{-1}(X_E'Y - \lambda_E s_E)) = s_E. \]
Allowing some \(\lambda_i\)’s to be zero changes things a little – only have conditions for \(\lambda_i > 0\).
\[ \begin{aligned} \nabla \ell(\hat{\beta}_E, 0)_{-E} &\approx \nabla \ell(\bar{\beta}_E, 0)_{-E} + \nabla^2 \ell(\bar{\beta}_E,0)[-E,E](\hat{\beta}_E - \bar{\beta}_E) \\ & \approx \nabla \ell(\bar{\beta}_E, 0)_{-E} - \nabla^2 \ell(\bar{\beta}_E,0)_{-E} \nabla^2 \ell^E(\bar{\beta}_E)^{-1} \lambda_E s_E \end{aligned} \]
\[ \|\nabla \ell(\hat{\beta}_E, 0)_{-E}/\lambda_{-E}\|_{\infty} \leq 1. \]
For any fixed \(E\), \(\nabla \ell(\bar{\beta}_E, 0)_{-E}\) will by asymptotically Gaussian under standard conditions. It will have mean 0 if the model \(E\) is correctly specified.
The vector
\[ \nabla^2 \ell(\bar{\beta}_E,0)_{-E} \nabla^2 \ell^E(\bar{\beta}_E)^{-1} \lambda_E s_E \]
will behave as a fixed vector (with signs fixed).
\[ \|(X_{-E}'(Y - P_EY) + X_{-E}'X_E(X_E'X_E)^{-1} \lambda_Es_E)/\lambda_{-E} \|_{\infty} \leq 1. \]
Now suppose that model is correct with parameter \(\beta^*\) such that \(\beta^*_{-A}=0\).
When will the LASSO recover \(A\) with correct signs \(\text{sign}(\beta^*_A)\)? (For simplicity let’s now set all \(\lambda_i\)’s equal).
References (among others): Zhao and Yu, Candes and Plan
Our look at the active block of the KKT conditions says that if we solve the restricted MLE on \(A\) and we shrink we must still have the same signs.
Up to small remainder this event is
\[ \text{sign}(\bar{\beta}_A - \lambda \nabla \ell^2(\bar{\beta}_A) s^*_A) = s^*_A \]
with \(s^*_A=\text{sign}(\beta^*_A)\).
\[ \|(\nabla \ell(\bar{\beta}_A, 0)_{-A} - I_A \lambda s_A^*) / \lambda\|_{\infty} = \|(\nabla \ell(\bar{\beta}_A, 0)_{-A}/\lambda - I_A s_A^*) / \|_{\infty} \leq 1. \]
\[ \max_{\|u_A\|_{\infty}\leq 1} \|I_A u_A\|_{\infty} \leq 1 \]
The irrepresentable condition suggests \(\lambda\) should be such that \[ \|\nabla \ell(\bar{\beta}_A, 0)_{-A}/\lambda\|_{\infty} < 1. \]
A typical choice
\[ \lambda \approx C \cdot E[\|\nabla \ell(\beta_A^*,0)\|_{\infty}], \qquad C > 1. \]