Ordinary Least Squares Lecture Notes
Ordinary Least Squares Lecture Notes
François Portier
1
Please let me know if you find typos or mistakes ([Link]@[Link]). The author is grateful to Joseph
Salmon ([Link] for some help on the writing of this course and for sharing some materials.
2
Contents
2 Statistical model 13
2.1 The fixed-design model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.1 Bias, variance and risk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.2 Best linear unbiased estimator (BLUE) . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.3 Noise estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 The Gaussian model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2.1 The Cochran lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2.2 A concentration inequality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3 The random design model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4 Ridge regularization 29
4.1 PCA before OLS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2 Definition of the Ridge estimator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.3 Bias and variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.4 Choice of the regularization parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5 The LASSO 33
5.1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.2 Theoretical properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.3 Computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.4 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3
B Singular value decomposition and principal component analysis 41
B.1 Matrix decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
B.2 Principal component analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
C Concentration inequalities 43
4
Notations
• h·, ·i is the usual inner product in Rd . k · k is the Euclidean norm. The elements forming the canonical
basis of Rd are denoted by e0 , . . . , ed−1 . Additionally, the `q -norm of x ∈ Rd is denoted by kxkqq =
Pd q
k=1 xk .
• When A is a square invertible matrix, the inverse is denoted by A−1 . The Moore–Penrose inverse is
denoted by A+ . The trace of A is given by tr(A).
• The identity matrix in Rd×d is Id . The vector 1n ∈ Rn contains n ones.
Pn
• For any sequence z1 , z2 , . . ., the empirical mean over the n first elements is denoted by z n = i=1 zi /n
• When two random variables X and Y have the same distribution we write X ∼ Y .
• When Xn is a sequence of random variables that converges in distribution (resp. in probability) to X,
p
we write Xn X (resp. Xn → X).
5
6
Chapter 1
1.1 Definition
The general goal of regression is to predict with an output variable y ∈ R, also called the explanatory
variable, based on the observation of some input variables x = (x1 , . . . , xp )T ∈ Rp , with p ≥ 1, also called
the covariates. The statistical approach consists in learning or estimating a regression function (also called
link function) that maps any element x of the input space Rp to the output space R. Generally, the estimation
of the regression function is based on the observation of a sample made of examples. These examples are also
called the observations and each example is a pair made of an input variable together with the corresponding
output. Let n ≥ 1 denote the number of observations. Let (xi , yi )i=1,...,n be the observations such that for
each i, xi ∈ Rp and yi ∈ R. Many regression model can be estimated on the basis of these observations.
In this course, we focus on linear regression in which the regression function is defined as a simple linear
function, i.e., the variable y is modeled by θ0 + θ1 x1 + . . . + θp xp where (θ0 , . . . , θp ) are the parameters of the
linear regression function. In what follows we introduce the ordinary least squares (OLS) approach which
basically consists in minimizing the sum of squares of the distance between the observed values yi and the
predicted values at xi under the linear model.
We focus on a regression problem with n ≥ 1 observations and p ≥ 1 covariates. For notational conve-
nience, for i = 1, . . . , n, we consider yi ∈ R and zi = (xi,0 , . . . , xi,p )T = (xi,0 , xTi ) ∈ Rp+1 with xi,0 = 1.
This is only to include the intercept in the same way as the other coefficients. The OLS estimator is any
coefficient vector θ̂n = (θ̂n,0 , . . . , θ̂n,p )T ∈ Rp+1 such that
n
X
θ̂n ∈ argminθ∈Rp+1 (yi − ziT θ)2 . (1.1)
i=1
The matrix X which contains the covariates is called the design matrix. The matrix Z which contains the
covariates is called the extended design matrix. With the previous notation, (1.1) becomes
7
140
Raw data and fitted 140
Raw data and fitted
Data Data
120 OLS-sklearn-no-intercept 120 OLS-sklearn-w-intercept
OLS-sm-w-intercept
100 100
80 80
Distance
Distance
60 60
40 40
20 20
0 0
−20 −20
0 5 10 15 20 25 30 0 5 10 15 20 25 30
Speed Speed
Figure 1.1: The dataset is the cars dataset from the R software. We use sklearn to compute OLS. The graph
on the left represents the OLS line without intercept and the graph on the right is the OLS line computed
with intercept.
where k · k stands for the Euclidean norm. As soon as θ̂n is obtained, one can use it to define the estimated
regression function
p
X
ĝ(x) = θ̂n,0 + θ̂n,k xk .
k=1
This function is often called the predictor due to its use to predict the output value based on the observation
of the input x.
Z T (Y − Ŷ ) = 0.
Z T Z θ̂n = Z T Y. (1.2)
Note that in contrast with Ŷ (which is always unique), the vector θ̂n is not uniquely defined without further
assumptions on the data. For instance, take u ∈ ker(Z) then θ̂n + u verifies (1.2) as well as θ̂n . The
uniqueness of the OLS is actually determined by the kernel of Z which is related to the invertibility of the
so called Gram matrix introduce below (see Exercise 1).
Definition 1. The matrix Ĝn = Z T Z/n is called the Gram matrix. Denote by Ĥn,Z ∈ Rn×n the orthogonal
projector1 on span(Z).
1 Recall that P is the orthogonal projector on E, a subspace of Rn , if and only if P 2 = P , P T = P and ker(P ) = E ⊥ .
8
When the Gram matrix is invertible, the OLS is uniquely defined. When it is not the case, (1.1) has an
infinite number of solutions.
Proposition 1. The OLS estimator always exists and the associated prediction is given by Ŷ = Ĥn,Z Y . It
is either
(i) uniquely defined. This happens if and only if the Gram matrix is invertible, which is equivalent to
ker(Z) = ker(Z T Z) = {0}. In this case, the OLS has the following expression:
θ̂n = (Z T Z)−1 Z T Y.
(ii) or not unique, with an infinite number of solutions. This happens if and only if ker(Z) 6= {0}. In this
case, the set of solution writes θ̂n + ker(Z) where θ̂n is a particular solution.
Proof. The existence has already been shown using the Hilbert projection theorem. The linear system (1.2)
has therefore a unique solution or an infinite number of solutions depending on whether the Gram matrix is
invertible or not. Hence it remains to show that ker(Z) = ker(Z T Z) which follows easily from the identity
kZuk2 = uT Z T Zu.
When the OLS is not unique, the solution traditionally considered is
θ̂n = (Z T Z)+ Z T Y,
where (Z T Z)+ denotes the Moore–Penrose inverse of Z T Z, which always exists. For a demi-definite positive
symmetricPmatrix with eigenvectors ui and corresponding eigenvalues λi ≥ 0, the Moore–Penrose inverse is
given by i λ−1i u T
i i {λi >0} .
u 1
Corollary 1. The set of solution of OLS (1.1) is given by {(Z T Z)+ Z T Y + u : u ∈ ker(Z)}.
Proof. Let u ∈ ker(Z). Verify that (Z T Z)+ Z T Y + u is a solution (see exercise 7). Then assuming that v is
a solution, note that v − (Z T Z)+ Z T Y belongs to ker(Z).
and, assuming that Z has full rank, we have the following relationship between the traditional OLS and the
OLS based on centred data,
T
(θ̂n,1 , . . . , θ̂n,p ) = θ̂n,c .
Moreover, the 2 methods give the same predictor, i.e., for all x ∈ Rp , ĝ(x) = ĝc (x).
9
Proof. See exercise 9.
We conclude with the following proposition which expresses the uniqueness condition given in Proposition
1 in terms of X.
Proposition 3. The following conditions are equivalent:
(i) ker(Z) = {0}
(ii) ker(Xc ) = {0}
(iii) The empirical covariance matrix of X, defined as XcT Xc /n, is invertible
Proof. See Exercise 5.
Because of the orthogonality between Ŷ − Y and Ŷ and between Ŷ − Y and y n 1n , we have that
Pn
2 (ŷi − yi )2 kŶ − Y k2
R = 1 − ni=1 n 2 =1− . (1.3)
kY − y n 1n k2
P
i=1 (yi − y )
The last expression involves a new quantity, called the residual sum of squares, which is small as soon as the
OLS procedure went well, i.e., as soon as the predicted values are close to the observed values. Hence the
closer to 1 the R2 the better. The following statement justifies the use of the R2 as a score supporting the
quality of the OLS estimation :
• R2 = 1 if and only if Y = Ŷ .
• R2 = 0 if and only if Ŷ = Ĥ1n Y implying that θ̂n = (y n , 0, . . . , 0) is one OLS estimator.
Exercises
Exercise 1. Show that ker(Z T Z) = ker(Z) and that span(Z T ) = span(Z T Z) (for the latter, one might first
note that ker(Z) = span(Z T )⊥ ). Deduce that the normal equations always have at least one solution.
10
(c) Verify that ker(Z) = 0 if and only if the empirical covariance matrix Σ̂n is invertible (hint : one might
work on the condition that Σ̂n is non-invertible, i.e., there exists u ∈ Rp \{0} such that Xc u = 0).
(a) Verify that for any non-negative symmetric matrix A ∈ Rp×p , show that A+ A = A+ .
(b) Show that Z(Z T Z)+ Z T is idempotent and symmetric (making it an orthogonal projector).
(c) Using that Z(Z T Z)+ Z T writes as U U T for some matrix U that we shall specify, obtain that ker(Ĥn,Z ) =
ker(Z T ).
(c) Find ân such that, for any θ0 ∈ R and θ̃ ∈ Rp , kY − θ0 1n − X θ̃k ≥ kY − ân (θ̃)1n − X θ̃k.
Exercise 10 (on-line ols and cross-validation). The goal of this exercise is to show that the OLS estimator
θ̂n associated with design matrix X(n) ∈ Rn×(p+1) and output y(n) ∈ Rn can be easily updated when a new
pair of observation (xTn+1 , yn+1 ) ∈ R(p+1) × R is given. We apply the result to cross validation procedure in
the end.
To clarify the notation:
X(n) (n+1)×(p+1) y(n)
X(n+1) = ∈R , and y(n+1) = ∈ Rn+1
xTn+1 yn+1
We assume from now on that X(n) and X(n+1) are full column rank (i.e., the columns of each matrix are
independent vectors).
NB : Some of the questions require some computation (in particular obtaining (1.4) and (1.6)). Even if
you could not prove it, it can be use later.
(a) Let A, B, C, D be matrices with respective sizes (d, d), (d, k), (k, k), (k, d). Show that if A and C are
invertible, then
(A + BCD)−1 = A−1 − A−1 B(DA−1 B + C −1 )−1 DA−1 . (1.4)
11
(d) Show that the OLS estimator θ̂n+1 associated with design matrix X(n+1) and output y(n+1) can be
obtained as follows:
un+1
θ̂n+1 = θ̂n + ζn+1 , (1.6)
1 + bn+1
(g) The prediction of yn+1 given by the model is ŷn+1 := xTn+1 θ̂n+1 . With the following formula
un+1 bn+1
ŷn+1 = xTn+1 θ̂n + .
1 + bn+1
prove that
yn+1 − ŷn+1 = un+1 (1 − hn+1 ).
(h) Given some data (y, X), leave-one-out cross-validation consists in computing the risk
n
1X
Rcv = (yi − xTi θ̂(−i) )2
n i=1
where θ̂(−i) is the OLS estimator based on (y(−i) , X(−i) ), i.e., the data (y, X) without the i-th line.
Applying what have been done so far, show that
n
1X
Rcv = (yi − ŷi )2 /(1 − ĥi )2 ,
n i=1
with ĥi = xTi (X T X)−1 xi and ŷi = xTi θ̂n , θ̂n being the OLS estimator of (y, X).
12
Chapter 2
Statistical model
In the previous section, we have defined the OLS estimator based on the observed data without any assump-
tion on the generating process associated to the data. When assuming that the observations are independent
realizations of some random variables, we can rely on probability theory to further study the behaviour of
the OLS. In the following we describe different probabilistic models : fixed design model, random design
model and the Gaussian noise model.
n
For instance, (i ) can be an identically distributed and independent sequence of centred random variables
with variance σ 2 . The level of noise σ of course reflects the difficulty of the problem.
The fixed-design model is appropriate when the sequence (xi ) is chosen by the analyst, e.g., in a physics
laboratory experiment, one can fix some variables such as the temperature, or in a clinical survey one can
give to patients a determined quantity of some serum. In contrast, the random design (see Section 2.3)
model is appropriate when the covariates are unpredictable as for instance the wind speed observed in the
nature or the age of some individuals in a survey.
Based on this model, we can derive some statistical properties that we present in the following. These
properties are concerned with different types of error related to the estimation of θ ? by θ̂n and will be
obtained under the assumption that the dimension of span(X) equals p + 1, implying that ker(X) = {0} and
that θ̂n is unique. We therefore implicitly assume that n ≥ p + 1. We can now state a useful decomposition:
provided that ker(X) = {0}, it holds that
θ̂n − θ ? = (X T X)−1 X T . (2.1)
13
Definition 2. An estimator θ(X, Y ) is said to be unbiased if for all (X, , θ ? ) used to generate Y according
to the model, it holds that E[θ(X, Y )] = θ ? .
The risk measures the average error associated to an estimation procedure. Different notions of risk can
be defined: the quadratic risk is defined on the regression coefficients β, the prediction risk takes care of the
prediction error, i.e., the error when predicting y. Formal definitions are given below.
Definition 3. The quadratic risk associated to θ̂n estimating θ ? is
Rquad (θ̂n , θ ? ) = E[kθ̂n − θ ? k2 ].
The prediction risk is
Rpred (θ̂n , θ ? ) = E[kY ? − Ŷ k2 ]/n,
where Y ? is the prediction we would make if we knew the true regression vector, i.e., Y ? = Xθ ? .
Proposition 4. When ker(X) = {0}, the following holds:
(i) the OLS estimator is unbiased i.e., it holds that E[θ̂n ] = θ ? .
14
2.1.3 Noise estimation
Providing only an estimate θ̂n of θ ? is often not enough as it does not give any clue on the accuracy of the
estimation. When possible, one should also furnish an estimation of the error σ 2 . If one knew the residuals
(i ), one would take the empirical variance of 1 , . . . , n , but this is not possible. Alternatively, one can take
n
X
−1
σ̃n2 =n (Yi − Ŷi )2 .
i=1
Pn
Because of the first normal equations expressed in (1.2), we have i=1 (Yi − Ŷi ) = 0. Consequently, σ̃n2 is
simply the empirical variance estimate of the residual vector Yi − Ŷi . Noting that σ̃n2 = n−1 k(In − Ĥn,X )k2
one can compute the expectation:
E[σ̃n2 ] = σ 2 (n − p − 1)/n.
where from now on we assume that n > p + 1. In the case when n = p + 1 and X has rank p + 1, we obtain
that Yi = Ŷi for all i = 1, . . . , n.
where (xi ) is non-random sequence of vector in Rp+1 . We keep assuming that ker(X) = {0} in the following.
Proposition 6. Under the Gaussian model, if ker(X) = {0} and n > p + 1, it holds that
• (n − p − 1)(σ̂n2 /σ 2 ) ∼ χ2n−p−1 ,
15
Proof. For the first point, remark that X T and (I − Ĥn,X ) are two independent Gaussian vectors:
we see that θ̂n and σ̂ 2 are measurable transformations of two independent Gaussian vector. They then
are independent. We can use for instance the following characterisation of independence, say for random
variables ξ1 and ξ2 : for any f1 and f2 positive and measurable, E[f1 (ξ1 )f2 (ξ2 )] = E[f1 (ξ1 )]E[f2 (ξ2 )].
For the second point, as is Gaussian, one just has to compute the variance.
For the third point, let V ∈ Rn×n be an orthogonal matrix such that V = (V1 , V2 ) where V1 is a basis of
span(X), and note that V1T (I − Ĥn,X ) = 0 and V2T (I − Ĥn,X ) = V2T . As the norm is invariant by orthogonal
transformation, one has
(n − p − 1)σ̂ 2 = k(I − Ĥn,X )k2 = kV T (I − Ĥn,X )k2 = kV2T k2 .
Consequently,
n−p−1
X
(n − p − 1)(σ̂ 2 /σ 2 ) = ˜2i ,
i=1
with ˜ = V2T /σ. It remains to show that ˜ is a Gaussian vector with covariance In−p−1 .
For the fourth point, use the second point to obtain that
(n1/2 /ŝn,k σ)(θ̂n,k − θk? ) ∼ N (0, 1).
Then (n1/2 /ŝn,k σ̂n )(θ̂n,k − θk? ) writes as the quotient of two independent random variables: a Gaussian and
the square root of a chi-square. This is a Student’s t-distribution with n − p − 1 degrees of freedom.
A direct application of the previous proposition gives us the following equality, which is informative on
the estimation error, for any k = 0, . . . , p,
P(|θ̂n,k − θk? | ≥ t) = 2STn−p−1 (tn1/2 /ŝn,k σ̂n ),
where STn−p−1 is the survival function of the distribution Tn−p−1 .
16
Pn
Proof. Let X̃i = (X T X)−1 Xi . Apply Lemma 4 of Appendix C to the sequence i=1 (uT X̃i )i to obtain that
n
! n
!
X X
T 2 2 T 2
P (X̃i u)i > t ≤ 2 exp −t /(2σ (u X̃i ) ) ,
i=1 i=1
Pn
Choosing u = ek , we have i=1 (u
T
X̃i )2 = n−1 ŝ2n,k , and using (2.1), we obtain that
P θ̂n,k − θk? > t ≤ 2 exp(−t2 n/(2σ 2 ŝ2n,k )).
Choose t appropriately to obtain the first inequality. The second inequality follows from ŝ2n,k ≤ λ̂−1
n =
maxkuk=1 |uT Ĝ−1
n u| and the union bound:
[ n o
P max θ̂n,k − θk? > t = P |θ̂n,k − θk? | > t
k=0,...,p
k=0,...,p
X
≤ P θ̂n,k − θk? > t .
k=0,...,p
Remark 1. The first inequality of Proposition 7 is important as it shows that each coordinate might not
behave similarly depending
p on the associated diagonal element of Ĝn . For instance, for the intercept, the
bound just becomes 2σ 2 log(2/δ)/n. The quantity ŝn,k will play an important role in practice when building
confidence intervals (see section 3).
Remark 2. Proposition 7 suggests that the value of the smallest eigenvalue λ̂n of Ĝn plays a certain role
on the accuracy of the estimation. The smaller λ̂n the worst the estimation accuracy.
if and only if
inf E[(Y1 − Z1 )2 ],
Z1 ∈F
where F is the linear subspace of the Hilbert space L2 (Ω, A, P) generated by X1,0 , . . . , X1,p . As F is a closed
linear subspace (because it has a finite dimension), the minimizer is unique and characterized by the normal
equations.
17
The previous proposition does not imply that θ ∗ is unique. In fact we are facing a similar situation as
in Proposition 1 : either θ∗ is unique, which is equivalent to E[X1 X1T ] is invertible, or θ ∗ is not uniquely
defined. Note that θ ∗ is not unique whenever one variable is a combination of the others. In this case one
might consider any of the solution, e.g., θ ∗ = E[X1 X1T ]+ E[X1 Y1 ]. Some asymptotic properties are available.
They will be useful to run some statistical tests. We consider the following definition, valid for any n ≥ 1,
θ̂n = (X T X)+ X T Y.
Proposition 9. Suppose that E[X1 X1T ] and E[Y12 ] exist and that E[X1 X1T ] is invertible. Then
σ̂n2 → σ 2 , in probability.
It suffices to show that the term in the right converges to 0 in probability and that the term in the left
converges in distribution to the stated limit. The first point is a consequence of the continuity of the
determinant. The second point is a consequence of Slutsky’s theorem using the fact that the Moore-Penrose
inverse is a continuous operation. For more details, see Exercise 11.
The convergence of σ̂n2 is obtained by the decomposition
Invoking the law of large number, we only need to show that the term on the right goes to 0 in probability.
We have
n
!T n
!
X X
T T + T −1/2 −1/2
X(X X) X = n Xi i Ĝ+
n n Xi i
i=1 i=1
−1
Pn
Because Ĝ+
n →G and n−1/2 i=1 Xi i N (0, G), we get that
Remark 3. A more general regression problem can be formulated without specifying a linear link : the
regression function f ∗ is any measurable function that minimizes the risk
When E[Y12 ] < ∞, the minimizer is unique and coincides, in L2 (Ω, A, P), with the conditional expectation
of Y given X1 : f ∗ (X1 ) = E[Y1 |X1 ], almost surely.
18
Exercises
Exercise 11 (Asymptotics for the OLS in Random design). Let (X1 , Y1 ), (X2 , Y2 ), . . . be an i.i.d. sequence
(1) (p)
of random vectors. Each pair (Xi , Yi ) is valued in Rp × R. Denote by XiT = (Xi , . . . , Xi ). Suppose that
(k) (l)
for all (k, l) ∈ {1, . . . , p}2 , E[|X1 X1 |] < ∞ and G = E[X1 X1T ] is invertible. The goal is to show that
where θ ∗ is defined in Proposition 8. Recall that for each n ∈ N∗+ , the OLS is given by
n
!
X
θ̂n = Ĝ+
n n−1 Xi Yi , (2.2)
i=1
Pn
with Ĝn = n−1 i=1 Xi XiT .
1. Let Sp (R) be the space of symmetric matrices with real coefficients. Let T : Sp (R) → Sp (R) be such
that T (A) = A+ . Show the continuity of T at each point A such that det(A) 6= 0. We recall that for
any A such that det(A) 6= 0, A−1 = (det(A))−1 Com(A)T where Com : Sp (R) → Sp (R) is continuous
(it is called the comatrix).
19
20
Chapter 3
Definition 5. A confidence interval of level 1 − α is an interval Iˆn (Y, X) ⊂ R satisfying, for all n ≥ 1,
where Qn−p−1 is the quantile function of the distribution Tn−p−1 , is a confidence interval of level 1 − α.
21
y ∗ = xT θ ∗ . In the Gaussian model, using preservation properties of the Student’s distribution, we find the
following confidence interval CI(x) of level 1 − α. With probability equal to 1 − α,
y ∗ ∈ CI(x),
where
q
CI(x) = xT θ̂n ± Qn−p−1 (1 − α/2)σ̂ xT (X T X)−1 x,
Pn 2
and σ̂n2 = i=1 Yi − xTi θ̂n /(n − p − 1) (it has been introduced in Chapter 2). A related question is to
build a confidence interval on the value of y (not y ∗ ) under the true model. This can be done in a similar
manner as before but one needs to pay a particular attention to the additive noise in the model. Indeed, we
have that y = y ∗ + where ∼ N (0, σ 2 ). It follows that
y ∈ PI(x),
with
q
PI(x) = xT θ̂n ± Qn−p−1 (1 − α/2)σ̂ 1 + xT (X T X)−1 x.
For more details on the derivation of those confidence intervals, see Exercise 12.
is a confidence interval of level 1−α. If moreover, |i | ≤ c for all i = 1, . . . , n, then for each k ∈ {0, 1, . . . , p},
the interval
h p p i
θ̂n,k + − 2c log(2/α)c/n , 2c log(2/α)/n ,
22
Applying Hoeffding inequality with the sequence (i ), one has
n
!
X
P(|θ̂n,k − θk? | ≥ t) ≤ 2 exp −2(nt) /2
(bi − ai )2 ,
i=1
where Φ− is the quantile function of the distribution N (0, 1), is, asymptotically, a confidence interval of level
1 − α, i.e.,
Proof. That Xn N (0, 1) means that P (Xn ∈ [−Φ− (1 − α/2), Φ− (1 − α/2)]) → Φ(Φ− (1 − α/2)) −
−
Φ(Φ (α/2)) = 1 − α where Φ is the cumulative distribution function of N (0, 1).
3.2.1 Definitions
Statistical testing aims at answering whether or not an hypothesis H0 is likely. It is usually performed by
constructing a test statistic T̂n and deciding to reject, or not, whenever T̂n is in R, or not. The region R is
called the reject region. As soon as T̂n and R are specified, the process is quite simple:
The terminology “not to reject” rather than ”to accept” comes from the fact that H0 is often too much thin
and unlikely to be “accepted”, e.g., a simple hypothesis θ1? = 3.14159. There are basically 2 kinds of error
that we wish to control:
The proportion of Type-1 errors is called the level of the test. One minus the proportion of Type-2 errors is
called the power of the test. The consistency imposes that, for any level 1 − α, asymptotically, the level is
smaller than α while the power is one. To achieve consistency, it is natural to let the reject region depend
on α.
23
Definition 6. A statistical test (T̂n , Rα ) is said to be (asymptotically) consistent whenever for all level
1 − α ∈ (0, 1)
lim sup PH0 (T̂n ∈ Rα ) ≤ α
n→∞
Remark 4. In practice, a standard choice is α = 0.05. Of course when the sample size is too small one
cannot be too demanding and larger values of α might be more reasonable.
Proposition 13. Under the random design model, if E[X1 X1T ] and E[Y12 ] exist and E[X1 X1T ] is invertible,
the statistic and reject region, respectively given by
1/2
n
T̂n,k = |θ̂n,k |,
ŝn,k σ̂n
Rα = (Φ− (1 − α/2), +∞),
produce a consistent test.
Proof. For the level, it is very similar to confidence interval. For the power, suppose that θk? 6= 0. Let
Zn = (n1/2 /ŝn,k σ̂n )(θ̂n,k − θk? ) and q = Φ− (1 − α/2). Then T̂n,k ∈ Rα if and only if
Zn + (n1/2 /ŝn,k σ̂n )θk? < −q or Zn + (n1/2 /ŝn,k σ̂n )θk? > q.
If θk? is positive (resp. negative) one can show that the event on the right (resp. left) has probability going to
1. We consider only the case θk? > 0. It has been shown in the proof of Proposition 9 that ŝn,k σ̂n converges
in probability to a finite value. We can work on the event that ŝn,k σ̂n < M . Let K > 0. For n large enough
q − (n1/2 /ŝn,k σ̂n )θk? < −K. Hence
24
age sex bmi bp Serum measurements output
patient x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 y
1 59 2 32.1 101 157 93 38 4 4.9 87 151
2 48 1 21.6 87 183 103 70 3 3.9 69 75
··· ··· ···
··· ··· ···
441 36 1 30.0 95 201 125 42 5 5.1 85 220
442 36 1 19.6 71 250 133 97 3 4.6 92 57
Table 3.1: The dataset is composed of n = 442 patients, p = 10 variables “baseline” body mass index,
bmi), average blood pressure (bp), etc... The output is a score corresponding to the disease evolution. Each
covariate has been standardized Efron et al. (2004).
Remark 7 (test and confidence intervals). Making no effect tests consists in rejecting whenever 0 (or more
generally any tested values) is not lying inside the confidence interval. For instance, in the random design
model, to reject is equivalent to
n1/2
|θ̂n,k | ∈ (Φ− (1 − α/2), +∞),
ŝn,k σ̂n
which is equivalent to
ŝn,k σ̂n − ŝn,k σ̂n −
0∈
/ θ̂n,k + − Φ (1 − α/2) , Φ (1 − α/2) .
n1/2 n1/2
Another quantity of interest is ŝn (X̃k )2 = eT1 Ĝn (X̃k )−1 e1 . The criterion used to compare the importance of
each variable is the test statistic of the test of no effect, computed within each submodel:
25
values of the t-stat at each steps
40 step 0
step 1
step 2
30
20
10
0
0 2 4 6 8
features
Figure 3.1: The statistics of each selected variable is 0 in the next step. The intercept is the first selected
variable, then X3 , etc...
Hence taking the largest T̂n (Y, X̃k ) is equivalent to take the smallest p-value for the underlying test of no
effect. A stopping rule can be based on the p-value: stop as soon as none of the p-value is smaller than
0.05. As soon as one variable, say X̃k , is selected, one needs to account for the predictive information it
has brought in the modeling of Y . This is to prevent from selecting 2 identical covariates. This is done by
replacing the output Y by the residual Y − (1n , X̃k )θ̂n (Y, X̃k ).
Algorithm 1 (forward variable selection).
Inputs: (Y, X) a threshold pstop . Start with r = Y , S = ∅ ⊂ A = {0, . . . , p}.
(i) For each k ∈ A\S, compute T̂n (r, X̃k ).
(ii) Stop if no p-values are smaller than pstop .
Else compute k ∗ ∈ argmax T̂n (r, X̃k ).
And update S = S ∪ {k ∗ } and r = r − (1n , X̃k∗ )θ̂n (Y, X̃k∗ ).
Figure 3.3 illustrates the procedure described by Algorithm 1 applied to the “diabetes” dataset of sklearn
presented in Table 3.1.
Remark 8. Different stopping rules might be considered. For instance, in Zhang (2009), the authors rec-
ommend to consider the residuals sum of squares and to stop as soon as krk2 < .
Exercises
Exercise 12 (explicit formulas when p = 1 for prediction intervals). Let us consider the following fixed-design
one-dimensional (p = 1) linear regression model:
Yi = β0 + β1 xi + i , i ∼ N (0, σ) i.i.d. , i = 1, ..., n .
Being a particular but simply interpretable Pncase it facilitates intuitive
Pn understanding and enables easy two-
n −1 n −1
dimensional visualization.
Pn Let x = n x
i=1 i and Y = n i=1 Yi . We further assume that xi is not
constant, i.e., that i=1 (xi − xn )2 6= 0.
26
2. Show that
1 xn2 1
eT0 (X T X)−1 e0 = + Pn n 2 and eT1 (X T X)−1 e1 = Pn n 2,
n i=1 (xi − x ) i=1 i − x )
(x
3. Give the distribution of V[β̂0 ]−1/2 (β̂0 − β0 ) and V[β̂1 ]−1/2 (β̂1 − β1 )
1 xn2 σ̂ 2
V[β̂0 ] = σ̂ 2 + Pn n 2 and V[β̂1 ] = Pn n2 2 ,
n i=1 (xi − x ) i=1 (xi − x )
1
Pn 2
where σ̂ 2 = n−2 i=1 Yi − (β̂0 + β̂1 xi ) .
4. Give the reject region for the test H0 : βj = 0.
5. For a new pair (Y, x) observed from the Gaussian model above, the value β̂0 + β̂1 x is called the point
prediction. Show that
6. Build confidence intervals for (β0 + β1 x) and Y . Note that these intervals correspond, respectively, to
CI and PI given in section 3.1.1. The last one is often called prediction interval.
27
28
Chapter 4
Ridge regularization
In this chapter we use the singular-value decomposition (SVD), a matrix decomposition presented in Ap-
pendix B. The SVD of X shall provide useful expression for quantities related to the OLS estimate. The
SVD is also important to understand principal component analysis (PCA), a method that compresses the
data without loosing too much information, also presented in Appendix B.
The ridge estimator is introduced to overcome the issues caused by poorly conditioned Gram matrix
Ĝn , i.e., P
when some of the eigenvalues are too small. As indicated by the singular-value decomposition
r
of X = k=1 si ui viT , where r stands for the rank of X and si (resp. ui and vi ) are the singular-values
Pr
(resp. singular-vector) of X, we have that θ̂n = k=1 si vi uTi y. Consequently, the estimate is numerically
unstable as soon as some of the si are close to 0. As we can see looking at the variance of the OLS or at
Proposition 7, the smallest eigenvalues of Ĝn have a bad influence on the statistical behaviour of the OLS.
The ridge estimator is a solution to control these bad effects due to poor conditioning. Before going through
the definition of the ridge estimator, we discuss another method which consists in doing PCA before running
OLS.
For ease of notation (to avoid working with X̃c as before), in the rest of the chapter, we consider the
formulation of OLS without intercept with centered variable Y ∈ Rn and X ∈ Rn×p . As established in
Proposition 2, this is equivalent to include an intercept in the OLS with non-centered variables.
29
in which, by Proposition 26, the last term should be small. However, the second term in the right hand
side might be large. The lack of guarantee for this approach is due to the fact that the PCA used from the
beginning is independent of the output Y . Doing such a process might result in some loss in accuracy.
where λ > 0, called the regularization parameter, is fixed by the analyst. Before dealing with the choice of
λ, we describe some properties of the ridge estimate. First of all, let us briefly state some simple remarks:
• As the expression in (4.1) is a Lagrangian with constraint kθk2 ≤ c the Ridge is an OLS under
constraints. The link between c and λ is not explicit.
• To make the ridge estimate scale invariant, one might replace X by XD−1/2 where D is the diagonal
matrix with entries eTk X T Xek . Actually, this normalization permits to justify having 1 single parameter
λ to control the influence of the penalty. The ridge estimate is classically defined without intercept (to
prevent from penalizing the intercept). Hence one needs to first center Y and X so that the intercept
of the OLS is automatically 0.
Proof. Let f denote the objective function of (4.1). Considering the behaviour of f at the limit of the
domain, there exists A such that whenever kθk > A, f (θ) > f (0). But the set kθk ≤ A is compact and so a
minimum exists and is achieved. Note that for any θ,
with A = ((X T X) + nλIp )1/2 a positive matrix. For uniqueness, note that, for any u and v, we have
Then suppose that θ1 and θ2 are two distinct minimizers with f ∗ = f (θ1 ) = f (θ2 ). We have, from (4.2),
f (tθ1 + (1 − t)θ2 )
= tf (θ1 ) + (1 − t)f (θ2 ) − t(1 − t)kA(θ1 − θ2 )k2 < f ∗ .
(rdg)
Hence θ̂n is unique. The first order equation is
((X T X) + nλIp )θ = X T Y.
30
4.3 Bias and variance
We have seen that, similarly to the OLS, the ridge estimator is the solution of a linear system of equations.
In the ridge system of equations the matrix that was previously X T X in the OLS is now replaced by
X T X + nλIp . As λ is chosen by the user, it allows us to control the smallest eigenvalue of the underlying
Gram matrix. Such a change of course influence the bias and the variance of the estimate. To express these
quantities, we consider the fixed design model.
Proposition 15. In the fixed-design model :
(rdg)
(i) The bias of the ridge is E[θ̂n ] − θ ? = −λn(X T X + nλIp )−1 θ ?
(rdg)
(ii) The variance of the ridge estimator expresses as var(θ̂n ) = σ 2 (X T X + nλIp )−1 X T X(X T X +
nλIp )−1 .
(rdg)
(iii) We have that var(θ̂n ) < var(θ̂n ), where θ̂n is the OLS solution.
Proof. For the last point, we use the SVD of X to write that
p
X s2k
var(θ̂n(rdg) ) = σ 2 ui uTi .
(s2k + nλ)2
k=1
Doing the same for θ̂n and using that λk /(λk + λ)2 < 1/λk , we obtain the result.
The quantity R̂(λ) reflects the prediction risk associated to λ. It is then natural to minimize R̂ over
λ ∈ (0, ∞). In practice, this is usually done by taking a finite grid.
Remark 9. A computational advantage of using the SVD is that even if considering many values of λ the
SVD could be done once for each fold.
31
Exercises
Pr
Exercise 13. Recall the SVD of X = V SU T = k=1 si vk uTk where r = rank(X).
Pr Pr
1. Show that θ̂n = k=1 s−1 T +
k uk vk y = X Y and its variance is var(θ̂n ) = σ
2 −2 T
k=1 si uk uk .
2. Show that
(hint : one might prefer to use the complete SVD rather than its reduced form)
3. If n p, give an efficient method that would compute the Ridge estimator and would cost less than
the formula of Proposition 14. Compare the number of operations required.
32
Chapter 5
The LASSO
The LASSO (least absolute shrinkage and selection operator), introduced in Tibshirani (1996) is a regression
technique that consists in minimizing the usual least-squares loss with an `1 -norm regularization. As another
regularization method, it is similar to the Ridge method, presented in the previous chapter, which uses the
`2 -norm to regularize. In contrast with the Ridge, some of the LASSO coefficients are usually equal to 0,
meaning that the corresponding variables are no longer included in the predictive model. The LASSO thus
achieves in the mean time estimation and variable selection.
5.1 Definition
As for the Ridge estimator, the LASSO is usually defined with centered variables so that we can skip
estimating the intercept. We consider the following framework: X ∈ Rn×p denote the covariates vector is
such that 1Tn X = 0 and Y ∈ Rn is the output and satisfies 1Tn Y = 0. In other words, X and Y are supposed
to have (empirical) mean 0. The LASSO estimate is defined by
1 2
θ̂LASSO ∈ argminθ∈Rp kY − Xθk2 + λkθk1 , (5.1)
2
where k · kq stands for the `q -norm. Some remarks are of order:
• Note that the solution of (5.1) can be recovered by working with non centered variables X and Y and
adding an intercept.
• As for the Ridge, it is standard to let the LASSO estimate be scale invariant. This is usually done
by an additional standardization step that consists in using XD−1/2 in place of X, where D is the
diagonal matrix with entries eTk X T Xek , k = 1, . . . , p (ek being the k-th element of the canonical basis
of the space Rp ).
• The LASSO is not unique. Some conditions for uniqueness are given and discussed in Tibshirani (2013).
• In contrast with the Ridge approach, the `1 -penalty of the LASSO objective function allows to shrink
to 0 the coefficients in θ̂LASSO associated to the variables that are useless to predict Y .
33
Figure 5.1: Graphical representation of the Ridge and LASSO penalties with the level set of the quadratic
loss.
S ∗ = {j = 1, . . . , p : θj∗ 6= 0}.
The number of elements in S ∗ , that we denote by s, quantifies the level of sparsity associated to the regression
model. We will see that the generalization bounds for the LASSO improve whenever s becomes small. We
follow the approach presented in Hastie et al. (2015), in which the theoretical analysis of the LASSO is carried
out using the restricted eigenvalue condition. This condition is basically dealing with the smallest eigenvalue
of the matrix X T X. It is called “restricted” because it is concerned only with particular eigenvectors that
are “away” from the not active directions. More precisely, it only considers vectors living in certain cone
that leaves away the direction S ∗c . The collection of cones of interest are now defined. For α > 0 and
S ⊂ {1, . . . , p}, we set
The following lemma is crucial to understand the role played by the cone C(3, S ∗ ) in the analysis of the
LASSO.
Lemma 1. Whenever λ ≥ 2kX T k∞ , then
From the triangle inequality, k(θ ∗ − (−û))S ∗ k1 ≥ |kθS∗ ∗ k1 − kûS ∗ k1 | ≥ kθS∗ ∗ k1 − kûS ∗ k1 , implying that
34
From Holder inequality, we get h, X ûi ≤ kX T k∞ kûk1 , which leads to
kX ûk22 /2 ≤ kX T k∞ kûk1 + λ(kûS ∗ k1 − kûS ∗c k1 ).
Now we can state the main result dealing with the analysis of the LASSO error.
Theorem 1. Under the Gaussian model (5.2), p assume that ∀k ∈ {1, . . . , p}, (X T X)k,k ≤ n and that RE for
∗
(γ, 3, S ) is satisfied. Then provided that λ = 2 2nσ 2 log(2p), we have with probability 1 − δ that
64sσ 2 log(2p)
kX(θ̂LASSO − θ ∗ )k22 ≤ .
γ
In addition, we have with probability 1 − δ that
r
∗ 6 2σ 2 s log(2p)
kθ̂LASSO − θ k2 ≤ .
γ n
Proof. Let û = θ̂LASSO −θ ∗ . Suppose for now that λ ≥ 2kX T k∞ (this will be shown to hold with probability
1 − δ at the end of the proof). We have, from (5.4) and Jensen inequality, that
√ √
kX ûk22 ≤ 3λkûS ∗ k1 ≤ 3λ skûS ∗ k2 ≤ 3λ skûk2 . (5.5)
By Lemma 1 and the RE condition, it holds that
kûk22 ≤ (γn)−1 kX ûk22 .
Injecting this in (5.5), we obtain the first and second statement. It remains to show that with probability
1 − δ, λ ≥ 2kX T k∞ . This follows from the use of Lemma 4, a Gaussian concentration result stated in
Appendix C. Let k ∈ {1, . . . , p}, note that (X T )k is distributed as N (0, (X T X)k,k σ 2 ). Applying Lemma 4
gives that
P(|(X T )k | > t) ≤ 2 exp(−t2 /(2(X T X)k,k σ 2 )).
From the union bound, it follows that
P(kX T k∞ > t) ≤ (2p) exp(−t2 /(2nσ 2 )),
or equivalently, that with probability 1 − δ,
p
kX T k∞ ≤ 2nσ 2 log(2p/δ) = λ/2.
Some other (asymptotic) properties of the LASSO are derived in Knight and Fu (2000). The authors
assume the following
n−1 X T X → C, a positive definite matrix, (5.6)
and
(Yi − θ0? − XiT θ ? )i is an iid sequence with mean 0 and variance σ 2 . (5.7)
Theorem 2 (Knight and Fu (2000)). Suppose that (5.6) and (5.7) hold and that λ/n → 0, then θ̂LASSO →
√ √
θ ? , in probability. If moreover λ/ n → λ0 ≥ 0, then n(θ̂LASSO − θ ? ) converges weakly.
35
5.3 Computation
In contrast with the OLS or the Ridge, we have no closed formula for the LASSO solutions. This is due
to the lack of smoothness of the `1 -norm. In particular, the traditional first order conditions are derived
using subgradients (rather than gradients). In Appendix D, some basic definitions and properties are given
concerning subgradients and subdifferentials.
The following remark is helpful to characterize the set of LASSO solutions : if f : Rp → R is a convex
function, the point x? is a minimum if and only if 0 ∈ ∂f (x? ), where ∂f is the subdifferential of f (see
Appendix D for details). This is often refereed to as the Fermat’s rule.
Proposition 16. Denote by Xk the k-th column of X. The LASSO solution satisfies
{sign(θ̂LASSO,k )} if θ̂LASSO,k 6= 0
∀k = {1, . . . , p}, hXk , Y − X θ̂LASSO i ∈
[−1, 1] if θ̂LASSO,k = 0
Actually, the previous set of equations has no explicit solutions. The LASSO problem becomes much
simpler when we fix all coordinates except one, and try to minimize with respect to this coordinate. For this
reason, the LASSO is usually computed using a coordinate descent, i.e., by iteratively solving the first order
conditions (involving subgradients) for each coordinate. For any λ ≥ 0, define the function ηλ : R → R given
by
z+λ if z < −λ
ηλ (z) = 0 if z ∈ [−λ, λ] (5.8)
z−λ if z > λ
The function ηλ intervenes in solving least-squares with an absolute penalty (see Exercise 14). Note that
ηλ (z) = sign(z)(|z| − λ)+ . As shown in the following development, the function η is useful to update
the LASSO in the coordinate descent algorithm. To avoid trivial cases, we suppose in the following that
kXk k2 6= 0. In practice, one just need to remove the constant variables. Let
X
zk = Yk − Xj θj .
j6=k
Minimizing (5.1) with respect to the k-th coordinates is the same as minimizing
1 2 2
(kzk − Xk θk k2 − kzk k2 ) + λ|θk |
2
1 2 2
= (−2hzk , Xk iθk + θk kXk k2 ) + λ|θk | ,
2
As it is standard, one can start with a Ridge solution and then update each coordinates with the previous
formula.
36
5.4 Extensions
Among the extension of the LASSO, we have the LSLASSO (Least-Square LASSO) which consists in (i)
running the LASSO to find the support and (ii) applying OLS on the non-zero coefficients. Another extension
of LASSO is Elastic Net, introduced in Zou and Hastie (2005), which computes the regression coefficient
1 1
θ̂E-NET ∈ argminθ∈Rp kY − Xθk22 + λ{αkθk1 + (1 − α)kθk22 } . (5.9)
2 2
The previous estimate is unique. Finally, a notable extension is adaptive LASSO, introduced in Zou (2006).
The adaptive LASSO is an iterative strategy that attributes weights to each coefficient |θk | in the penalty
1/2
term. The weights might take the form 1/θ̂OLS,k penalizing mostly the small OLS coefficients. The resulting
estimate recover the support with probability going to 1.
Exercises
Exercise 14. Show that ηλ (z) = argminx∈R {(z − x)2 /2 + λ|x|} where ηλ is defined in (5.8).
Exercise 15. Following the approach given for the LASSO, find the update for the Elastic Net defined in
(5.9).
37
38
Appendix A
where uT stands for the transpose of u. If hu, vi = 0 we say that u and v are orthogonal and we write u ⊥ v.
If E is a set of vector in Rd , we define its orthogonal complement as
E ⊥ = {u ∈ Rd : xT u = 0, ∀x ∈ E}.
span(A) = {Ax : x ∈ Rd },
ker(A) = {x ∈ Rd : Ax = 0}.
The set span(A) is called the image of the matrix A. It is the linear space generated by the columns of A.
The set ker(A) is called the kernel of A. Both sets are linked by the following property.
Proposition 19. Let A ∈ Rp×d . Then ker(A) = {0} if and only if span(AT ) = Rd . Consequently, if p < d
then ker(A) 6= {0}.
2. S = ∅,
S = x0 + ker(A).
39
We now recall a classical result called the spectral decomposition of symmetric matrices or the eigen
decomposition of symmetric matrices.
Proposition 22. Let A ∈ Rd×d be a symmetric matrix. Then there exist λ1 ≥ . . . ≥ λd , called eigenvalues,
and an orthonormal matrix U ∈ Rd×d (i.e., U T U = Id ) of eigenvectors, such that A = U DU T , where
D = diag(λ1 , . . . , λd ).
40
Appendix B
Before we present the method of principal component analysis (PCA), it is appropriate to recall some matrix
decomposition results and more particularly the singular value decomposition (SVD).
X = V SU T ,
where S ∈ Rn×p contains 0 everywhere except on the diagonal formed by (s1 , . . . , smin(n,p) ) .
Proof. Without loss of generality, we suppose that p ≤ n. Otherwise we apply the result to the X T .
Applying Proposition 22 to X T X, there exists U ∈ Rp×p such that U T (X T X)U is diagonal with r positive
coefficients. Hence U1T (X T X)U1 = D ∈ Rr×r and XU2 = 0. Take V1T = D−1/2 U1T X T (an orthogonal set of
r vectors : V1T V1 = Ir ) to find that V1T XU1 = D1/2 . Consequently, V1T X(U1 , U2 ) = (D1/2 , 0). Remarking
that v orthogonal to V1 means that v T XU1 = 0 implying that v T X(U1 , U2 ) = 0 leading to v T X = 0.
Now taking V2 such that V = (V1 , V2 ) ∈ Rn×p is orthogonal, we obtain the claimed decomposition with
S 2 = diag(d1 , . . . , dp ).
We have the following reduced SVD formula, if r ≥ 1 stands for the dimension of span(X),
where Ũr = (U1 , . . . , Ur ), Ṽr = (V1 , . . . , Vr ), and S̃r ∈ Rr×r contains only the positive singular-values.
An attractive property of the SVD is that it defines subspaces on which one can project the data X
without loosing too much.
Proposition 26. Let X ∈ Rn×p . For any projector P ∈ Rp×p with rank smaller than k, it holds that
kX − XPk kF ≤ kX − XP kF ,
Ui UiT .
P
where Pk = i≤k
41
Proof. Suppose that 1 ≤ k < r. By Pythagorean identity, kX − XP k2F = kXk2F − kXP k2F . Hence one just
has to show that kXPk k2F ≥ kXP k2F . Considering the reduced SVD X = Ur Sr VrT , we have
kXP k2F = tr (P Ur )S 2 (P Ur )T
X
= tr s2i Wi Wi
i≤r
X
= s2i kWi k22 ,
i≤r
with Wi = P Ui and the constraints that kWi k22 ≤ 1 and i≤r kWi k22 ≤ k. Note that this corresponds to the
P
optimization problem
X X
max s2i mi u.c. mi ∈ (0, ki ), mi ≤ k,
m1 ,...,mr0
i≤r 0 i≤r 0
0
r 0 with r ≤ r and ki ≥ 1 stands for the multiplicity. We derive the
in which we suppose that s1 < . . . < sP
maximum. Note first that necessarily i≤r0 mi = k. Then if i is the first index such that 0 < mi < ki , the
function cannot achieve its P
maximum. Then we get that the maximizer is achieved when mi is either 0 or
1. Clearly the maximum is i≤k s2i which is achieved when P = i≤k Ui UiT .
P
Proposition 27. The principal components U = U1 , . . . Uk forms a set of orthonormal vectors along which
the empirical variance is maximal, i.e.,
X X
UiT Σ̂n Ui ≥ ŨiT Σ̂n Ũi ,
i≤k i≤k
for any (Ũ1 , . . . , Ũk ) orthonormal vectors. The principal components U can be obtained by an eigendecom-
position of Σ̂n .
Proof. Take Ũ and U as define in the statement. Define P̃ = Ũ Ũ T and P = U U T , the associated projectors
of rank k. Write
X
UiT Σ̂n Ui = tr(Σ̂n P ) = n−1 tr(XcT Xc P ) = n−1 kXc P k2F .
i≤k
Using Proposition 26 and the Pythagorean identity, we get that kXc P k2 ≥ kXc P̃ k2F .
Remark 10. As the PCA of X depends on the scale of each covariate, one may prefer in practice to rescale
the matrix X before running the PCA algorithm. This can be done by taking XD−1/2 rather than X, with
D equal to the diagonal matrix whose elements are eTk Σ̂n ek , k = 1, . . . , n. Then each covariate of XD has
the same empirical variance.
42
Appendix C
Concentration inequalities
To derive concentration inequalities for the errors of the estimators, we use the notion of sub-Gaussianity as
defined for instance in (Boucheron et al., 2013, Section 2.3). Recall that the moment generating function of a
Gaussian random variable W with mean µ and variance σ 2 is equal to λ 7→ E[exp(λW )] = exp(µλ + λ2 σ 2 /2).
Definition 9. A centered random variable Y is sub-Gaussian with variance factor τ 2 > 0, notation Y ∈
G(τ 2 ), if log E[exp(λY )] ≤ λ2 τ 2 /2 for all λ ∈ R.
If Y ∈ G(τ 2 ), then necessarily var(Y ) ≤ τ 2 (Boucheron et al., 2013, Exercise 2.16). Centered, bounded
random variables taking values in an interval [a, b] are sub-Gaussian with variance factor at most (b − a)2 /4
(Boucheron et al., 2013, Lemma 2.2). Chernoff’s inequality provides exponential bounds on the tails of
sub-Gaussian random variables.
Lemma 2 (Chernoff). If Y ∈ G(τ 2 ), then P (Y > t) ≤ exp(−t2 /(2τ 2 )).
Proof. For any λ ∈ R, we have 1Y >t ≤ exp(λ(Y − t)). Hence it holds that P (Y > t) ≤ E[exp(λ(Y − t))] ≤
exp(λ2 τ 2 /2 − λt). Minimizing the previous bound in λ gives λ = t/τ 2 , from which we deduce that the stated
bound.
Finally, the sum of independent sub-Gaussian variables is again sub-Gaussian. This is the statement of
the following Lemma, which proof is left as an exercise.
2
Lemma i≥1 is a sequence of independent random variables such that, for all i ≥ 1, Yi ∈ G(τi ),
Pn 3. If (Yi )P n
then i=1 Yi ∈ G( i=1 τi ).
To conclude we state a concentration inequality for the sum of independent sub-Gaussian random vari-
ables. This is just a consequence of the two previous Lemma.
Lemma 4. If (Yi )i≥1 is a sequence of independent random variables such that, for all i ≥ 1, Yi ∈ G(τi2 ),
then, for all n ≥ 1, and t ≥ 0,
n
! n
!
X X
2 2
P Yi > t ≤ 2 exp −t /(2 τi )
i=1 i=1
.
43
44
Appendix D
We recall here some definitions and basic properties dealing with the minimization of convex functions.
Definition 10 (convex function). A function f : Rp → R is said to be convex if
As a consequence of the previous definition (when taking h = tek , t → 0) the partial derivatives (gradient)
exists for differentiable functions. The gradient of a differentiable function f at x ∈ Rp is denoted by ∇f (x).
45
Proposition 29 (differentiable function and convexity). A differentiable function f : Rp → R is convex if
and only if
Moreover, for any x ∈ Rp , the gradient ∇f (x) is the only vector satisfying the previous equation for any y.
Consequently, for differentiable and convex functions ∂f (x) = {∇f (x)}.
46
Bibliography
Boucheron, S., G. Lugosi, and P. Massart (2013). Concentration inequalities: A nonasymptotic theory of
independence. Oxford university press.
Efron, B., T. Hastie, I. Johnstone, R. Tibshirani, et al. (2004). Least angle regression. The Annals of
statistics 32 (2), 407–499.
Hastie, T., R. Tibshirani, and M. Wainwright (2015). Statistical learning with sparsity: the lasso and
generalizations. CRC press.
Knight, K. and W. Fu (2000). Asymptotics for lasso-type estimators. Annals of statistics, 1356–1378.
Tibshirani, R. (1996). Regression shrinkage and selection via the lasso. Journal of the Royal Statistical
Society. Series B (Methodological), 267–288.
Tibshirani, R. J. (2013). The lasso problem and uniqueness. Electronic Journal of Statistics 7, 1456–1490.
Zhang, T. (2009). Adaptive forward-backward greedy algorithm for sparse learning with linear models. In
Advances in Neural Information Processing Systems, pp. 1921–1928.
Zou, H. (2006). The adaptive lasso and its oracle properties. Journal of the American statistical associa-
tion 101 (476), 1418–1429.
Zou, H. and T. Hastie (2005). Regularization and variable selection via the elastic net. Journal of the Royal
Statistical Society: Series B (Statistical Methodology) 67 (2), 301–320.
47