March 19 2013
The linear regression t: Squared bias 0.006 Variance 0.627 Pred. error 1 + 0.006 + 0.627 1.633
0.0 0.2 0.4 0.6 0.8 1.0 True coefficients
Frequency
Prediction error
1.50
1.55
1.60
1.65
1.70
1.75
1.80
Low 0 5 10 15 20
High 25
Amount of shrinkage
Linear regression: Squared bias 0.006 Variance 0.627 Pred. error 1 + 0.006 + 0.627 Pred. error 1.633
Ridge regression, at its best: Squared bias 0.077 Variance 0.403 Pred. error 1 + 0.077 + 0.403 Pred. error 1.48
4
Ridge regression
Ridge regression is like least squares but shrinks the estimated coecients towards zero. Given a response vector y Rn and a predictor matrix X Rnp , the ridge regression coecients are dened as
n p
ridge = argmin
Rp i=1
2 (yi xT i ) + 2 2
2 j j =1 2 2
= argmin y X
Rp Loss
Penalty
Here 0 is a tuning parameter, which controls the strength of the penalty term. Note that: When = 0, we get the linear regression estimate ridge = 0 When = , we get For in between, we are balancing two ideas: tting a linear model of y on X , and shrinking the coecients
5
Linear
G G G G G G G G G G G
Ridge
G G G G G G G G G
Coefficients
0.5
0.0
G G G G G G G G G G G G
G G G G G G G G G G G G G G G
G G G G G G G G G G G G G G G G
0.5
0.0
0.5
1.0
1.5
2.0
2.5
Important details
When including an intercept term in the regression, we usually leave this coecient unpenalized. Otherwise we could add some constant amount c to the vector y , and this would not result in the same solution. Hence ridge regression with intercept solves 0 , ridge = argmin
0 R, Rp
y 0 1 X
2 2
2 2
If we center the columns of X , then the intercept estimate ends up 0 = y just being , so we usually just assume that y, X have been centered and dont include an intercept
p 2 Also, the penalty term 2 2 = j =1 j is unfair is the predictor variables are not on the same scale. (Why?) Therefore, if we know that the variables are not measured in the same units, we typically scale the columns of X (to have sample variance 1), and then we perform ridge regression 7
The bias and variance are not quite as simple to write down for ridge regression as they were for linear regression, but closed-form expressions are still possible (Homework 4). Recall that ridge = argmin y X
Rp 2 2
2 2
The general trend is: The bias increases as (amount of shrinkage) increases The variance decreases as (amount of shrinkage) increases What is the bias at = 0? The variance at = ?
0.0
Bias^2 Var 0 5 10 15 20 25
0.0
Ridge regression in R: see the function lm.ridge in the package MASS, or the glmnet function and package
10
Squared bias 0.006 Variance 0.628 Pred. error 1 + 0.006 + 0.628 1.634
0.0 0.2 0.4 0.6 0.8 1.0 True coefficients
Why are these numbers essentially the same as those from the last example, even though the true coecients changed?
12
Ridge regression can still outperform linear regression in terms of mean squared error:
Linear MSE Ridge MSE Ridge Bias^2 Ridge Var
0.0 0
0.5
1.0
1.5
2.0
10
15
20
25
30
Variable selection
To the other extreme (of a subset of small coecients), suppose that there is a group of true coecients that are identically zero. This means that the mean response doesnt depend on these predictors at all; they are completely extraneous. The problem of picking out the relevant variables from a larger set is called variable selection. In the linear model setting, this means estimating some coecients to be exactly zero. Aside from predictive accuracy, this can be very important for the purposes of model interpretation Thought 3: How does ridge regression perform if a group of the true coecients was exactly zero? The answer depends whether on we are interested in prediction or interpretation. Well consider the former rst
14
The linear regression t: Squared bias 0.006 Variance 0.627 Pred. error 1 + 0.006 + 0.627 1.633
0.0 0.2 0.4 0.6 0.8 1.0 True coefficients
Frequency
10
15
15
0.0 0
0.2
0.4
0.6
0.8
10
15
20
25
Remember that as we vary we get dierent ridge regression coecients, the larger the the more shrunken. Here we plot them again
G
1.0
G G G
G G G G
G G G G G
G G G
G G G G G G G G G G G
G G
The red paths correspond to the true nonzero coecients; the gray paths correspond to true zeros. The vertical dashed line at = 15 marks the point above which ridge regressions MSE starts losing to that of linear regression
5 10 15 20 25
Coefficients
0.5
0.0
0.5
An important thing to notice is that the gray coecient paths are not exactly zero; they are shrunken, but still nonzero
17
E.g., suppose that we are studying the level of prostate-specic antigen (PSA), which is often elevated in men who have prostate cancer. We look at n = 97 men with prostate cancer, and p = 8 clinical measurements.1 We are interested in identifying a small number of predictors, say 2 or 3, that drive PSA
2
1 2
Data from Stamey et al. (1989), Prostate specic antigen in the diag... Figure from http://www.mens-hormonal-health.com/psa-score.html
18
lcavol
0.6
0.4
Coefficients
svi
Coefficients
0.4
0.6
svi
lweightG
lweight
0.2
lbph G pgg45 G
G gleason
0.2
G G
lbph pgg45
gleason
0.0
lcp age
0.0
G G
G G
lcp age
200
400
600
800
1000
4 df()