{"word_count": 1362, "character_count": 13029}
This post is the eighth one of our series on the history and foundations of econometric and machine learning models. The first fours were on econometrics techniques. Part 7 is online here.Penalization and variables selectionOne important concept in econometrics is Ockham's razor – also known as the law of parsimony (lex parsimoniae) – which can be related to abductive reasoning.Akaike's criterion was based on a penalty of likelihood taking into account the complexity of the model (the number of explanatory variables retained). If in econometrics, it is customary to maximize the likelihood (to build an asymptotically unbiased estimator), and to judge the quality of the ex-post model by penalizing the likelihood, the strategy here will be to penalize ex-ante in the objective function, even if it means building a biased estimator. Typically, we will build: [latex display="true"](\widehat{\beta}_{0,\lambda},\widehat{\beta}_{\lambda})=\text{argmin}\left\lbrace\sum_{i=1}^n \ell(y_i,\beta_0+\mathbf{x}^T\beta)+\lambda \text{ penalization}( \boldsymbol{\beta})\right\rbrace, ~~~(11)[/latex]where the penalty function will often be a norm [latex]\|\cdot\|[/latex] chosen a priori, and a penalty parameter [latex]\lambda[/latex] (we find in a way the distinction between AIC and BIC if the penalty function is the complexity of the model - the number of explanatory variables retained). In the case of the [latex]\ell_2[/latex] norm, we find the ridge estimator, and for the [latex]\ell_1[/latex] norm, we find the lasso estimator ("Least Absolute Shrinkage and Selection Operator"). The penalty previously used involved the number of degrees of freedom of the model, so it may seem surprising to use [latex]\|\beta\|_{\ell_2}[/latex] as in the ridge regression. However, we can envisage a Bayesian vision of this penalty. It should be recalled that in a Bayesian model : [latex display="true"]\underbrace{\mathbb{P}[\boldsymbol{\theta}\vert\boldsymbol{y}]}_{\text{posterior}} \propto \underbrace{\mathbb{P}[\boldsymbol{y}\vert\boldsymbol{\theta}]}_{\text{likelihood}} \cdot \underbrace{\mathbb{P}[\boldsymbol{\theta}]}_{\text{prior}} [/latex]or[latex display="true"]\log\mathbb{P}[\boldsymbol{\theta}\vert\boldsymbol{y}]= \underbrace{\log \mathbb{P}[\boldsymbol{y}\vert\boldsymbol{\theta}]}_{\text{log likelihood}} + \underbrace{\log\mathbb{P}[\boldsymbol{\theta}]}_{\text{{penalty}}}[/latex]In a Gaussian linear model, if we assume that the a priori law of [latex]\theta[/latex] follows a centred Gaussian distribution, we find a penalty based on a quadratic form of the components of [latex]\theta[/latex].Before going back in detail to these two estimators, obtained using the [latex]\ell_1[/latex] or [latex]\ell_2[/latex] norm, let us return for a moment to a very similar problem: the best choice of explanatory variables. Classically (and this will be even more true in large dimension), we can have a large number of explanatory variables, [latex]p[/latex], but many are just noise, in the sense that [latex]\beta_j=0[/latex] for a large number of [latex]j[/latex]. Let [latex]s[/latex] be the number of (really) relevant covariates, [latex]s=\#S[/latex], with [latex display="true"]S=\{j=1,\cdots,p:\beta_j\neq 0\}[/latex]. If we note [latex]\mathbf{X}_S[/latex] the matrix composed of the relevant variables (in columns), then we assume that the real model is of the form [latex]y=\mathbf{x}_S^T \beta_S+\varepsilon[/latex]. Intuitively, an interesting estimator would then be [latex]\widehat{\beta}_S=[\mathbf{X}_S^T \mathbf{X}_S ]^{-1} \mathbf{X}_S^T \mathbf{y}[/latex], but this estimator is only theoretical because the set [latex]S[/latex] is unknown, here. This estimator can actually be seen as the oracle estimator mentioned above. One may then be tempted to solve [latex display="true"](\widehat{\beta}_{0,s},\widehat{\beta}_{s})=\underset{\beta_S\in\mathbb{R}^s}{\text{argmin}}\left\lbrace\sum_{i=1}^n \ell(y_i,\beta_0+\mathbf{x}^T\beta_S)\right\rbrace,\text{ s.t. } \# {S}=s [/latex]This problem was introduced by Foster &#38; George (1994) using the [latex]\ell_0[/latex] notation. More precisely, let us define here the following three norms, where [latex]\mathbf{a}\in\mathbb{R}^d[/latex], [latex display="true"]\Vert\boldsymbol{a} \Vert_{\ell_0}=\sum_{i=1}^d \mathbf{1}(a_i\neq 0), ~~ \Vert\mathbf{a} \Vert_{\ell_1}=\sum_{i=1}^d |a_i|~~\text{ and }~~\Vert\mathbf{a} \Vert_{\ell_2}=\left(\sum_{i=1}^d a_i^2\right)^{1/2} [/latex]Table 1: Constrained optimization and regularization.Let us consider the optimization problems in Table 1. If we consider the classical problem where the quadratic norm is used for [latex]\ell[/latex], the two problems of the equation [latex](\ell1)[/latex] of Table 1 are equivalent, in the sense that, for any solution [latex](\beta^\star,s)[/latex] to the left problem, there is [latex]\lambda^\star[/latex] such that [latex](\beta^\star,\lambda^\star)[/latex] is the solution of the right problem; and vice versa. The result is also true for problems[latex](\ell2)[/latex]. These are indeed convex problems. On the other hand, the two problems [latex](\ell0)[/latex] are not equivalent: if for [latex](\beta^\star,\lambda^\star)[/latex] solution of the right problem, there is [latex]s^\star[/latex] such that [latex]\beta^\star[/latex] is solution of the left problem, the reverse is not true. More generally, if you want to use an [latex]\ell_p[/latex] norm, sparsity is obtained if [latex]p\leq 1[/latex] whereas you need [latex]p\geq1[/latex] to have the convexity of the optimization program.One may be tempted to resolve the penalized program [latex](\ell0)[/latex] directly, as suggested by Foster &#38; George (1994). Numerically, it is a complex combinatorial problem in large dimension (Natarajan (1995) notes that it is a NP-difficult problem), but it is possible to show that if [latex]\lambda\sim\sigma^2 \log(p)[/latex], then [latex display="true"]\mathbb{E}\big([\mathbf{x}^T \widehat{\beta}-\mathbf{x}^T \beta_0]^2\big) \leq \underbrace{\mathbb{E}\big(\mathbf{x}_{ {S}}^T\widehat{\beta}_{{S}}-\mathbf{x}^T \beta_0]^2\big)}_{=\sigma^2 \#{S}}\cdot \big(4\log p+2+o(1)\big) [/latex]Observe that in this case [latex display="true"]\widehat{\beta}_{\lambda,j}^{\text{sub}} = \left\lbrace\begin{array}{l}0 \text{ if } j\notin{S}_\lambda(\beta)\\ \widehat{\beta}_{j}^{\text{ols}} \text{ if } j\in{S}_\lambda(\beta),\end{array}\right. [/latex]where [latex]S_\lambda (\beta)[/latex] refers to all non-zero coordinates when solving [latex](\ell0)[/latex].The problem [latex](\ell2)[/latex] is strictly convex if [latex]\ell[/latex] is the quadratic norm, in other words, the Ridge estimator is always well defined, with in addition an explicit form for the estimator, [latex display="true"]\widehat{ {\beta}}_\lambda^{\text{ ridge}}=(\mathbf{X}^T\mathbf{X}+\lambda\mathbb{I})^{-1}\mathbf{X}^T\mathbf{y}=(\mathbf{X}^T\mathbf{X}+\lambda\mathbb{I})^{-1}(\mathbf{X}^T\mathbf{X})\widehat{ {\beta}}^{\text{ ols}} [/latex]Therefore, it can be deduced that [latex display="true"]\text{bias}[\widehat{ {\beta}}_\lambda^{\text{ ridge}}]=-\lambda[\mathbf{X}^T\mathbf{X}+\lambda\mathbb{I}]^{-1}~\widehat{ {\beta}}^{\text{ ols}} [/latex]and[latex display="true"]\text{Var}[\widehat{\beta}_\lambda^{\text{ ridge}}]=\sigma^2[\mathbf{X}^T\mathbf{X}+\lambda\mathbb{I}]^{-1}\mathbf{X}^T\mathbf{X}[\mathbf{X}^T\mathbf{X}+\lambda\mathbb{I}]^{-1}[/latex]With a matrix of orthonormal explanatory variables (i.e. [latex]\mathbf{X}^T \mathbf{X}=\mathbb{I}[/latex]), the expressions can be simplified [latex display="true"]\text{bias}[\widehat{ {\beta}}_\lambda^{\text{ ridge}}]=\frac{\lambda}{1+\lambda}~\widehat{ {\beta}}^{\text{ ols}}\text{ and }\text{Var}[\widehat{ {\beta}}_\lambda^{\text{ ridge}}]=\frac{\sigma^2}{(1+\lambda)^2}\mathbb{I} [/latex]Observe that [latex]\text{Var}[\widehat{ {\beta}}_\lambda^{\text{ ridge}}]&#60;\text{Var}[\widehat{ {\beta}}^{\text{ ols}}][/latex]. And because  [latex display="true"]\text{mse}[\widehat{ {\beta}}_\lambda^{\text{ ridge}}]=\frac{p\sigma^2}{(1+\lambda)^2}+\frac{\lambda^2}{(1+\lambda)^2}\beta^T\beta [/latex]we obtain an optimal value for [latex]\lambda[/latex]: [latex]\lambda^\star=k\sigma^2/\beta^T\beta[/latex]On the other hand, if [latex]\ell[/latex] is no longer the quadratic norm but the [latex]\ell_1[/latex] norm, the problem [latex](\ell1)[/latex] is not always strictly convex, and in particular, the optimum is not always unique (for example if [latex]\mathbf{X}^T \mathbf{X}[/latex] is singular). But if it is strictly convex, then predictions [latex]\mathbf{X}\beta[/latex] will be unique. It should also be noted that two solutions are necessarily consistent in terms of sign of coefficients: it is not possible to have [latex]\beta_j&#60;0[/latex] for one solution and [latex]\beta_j&#62;0[/latex] for another. From a heuristic point of view, the program [latex](\ell1)[/latex] is interesting because it allows to obtain in many cases a corner solution, which corresponds to a problem resolution of type [latex](\ell0)[/latex] - as shown visually on Figure 2.Figure 2 : Penalization based on norms [latex]\ell_0[/latex], [latex]\ell_1[/latex] and [latex]\ell_2[/latex] (from Hastie et al. (2016)).Let us consider a very simple model: [latex]y_i=x_i \beta+\varepsilon[/latex], with a penalty [latex]\ell_1[/latex] and a loss function [latex]\ell_2[/latex]. The problem [latex](\ell1)[/latex] then becomes  [latex display="true"]\min\big\{\mathbf{y}^T\mathbf{y}-2\mathbf{y}^T\mathbf{x}\beta+\beta\mathbf{x}^T\mathbf{x}\beta+2\lambda|\beta|\big\} [/latex]The first order condition is then [latex display="true"]-2\mathbf{y}^T\mathbf{x} + 2\mathbf{x}^T\mathbf{x}\widehat{\beta}\pm 2\lambda=0[/latex]And the sign of the last term depends on the sign of [latex]\beta[/latex]. Suppose that the least square estimator (obtained by setting [latex]\lambda=0[/latex]) is (strictly) positive, i. e. [latex]\mathbf{y}^T \mathbf{x}&#62;0[/latex]. If [latex]\lambda[/latex] is not too big, we can imagine that [latex]\beta[/latex] is of the same sign as [latex]\widehat{\beta}^{\text{mco}}[/latex], and therefore the condition becomes [latex]-2\mathbf{y}^T \mathbf{x}+2\mathbf{x}^T \mathbf{x}\beta+2\lambda=0[/latex], and the solution is [latex display="true"]\widehat{\beta}_{\lambda}^{\text{ lasso}}=\frac{\mathbf{y}^T\mathbf{x}-\lambda}{\mathbf{x}^T\mathbf{x}} [/latex]By increasing [latex]\lambda[/latex], there will be a time such that [latex]\widehat{\beta}_λ=0[/latex]. If we increase [latex]\lambda[/latex] a bit little more, [latex]\widehat{\beta}_λ[/latex] does not become negative because in this case the last term of the first order condition changes, and in this case we try to solve [latex display="true"]-2\mathbf{y}^T\mathbf{x} + 2\mathbf{x}^T\mathbf{x}\widehat{\beta}- 2\lambda=0 [/latex]whose solution is then [latex display="true"]\widehat{\beta}_{\lambda}^{\text{ lasso}}=\frac{\mathbf{y}^T\mathbf{x}+\lambda}{\mathbf{x}^T\mathbf{x}}[/latex]But this solution is positive (we assumed [latex]\mathbf{y}^T \mathbf{x}&#62;0[/latex]), and so it is possible to have [latex]\widehat{\beta}_\lambda &#60;0[/latex]at the same time. Also, after a while, [latex]\widehat{\beta}_\lambda=0[/latex], which is then a corner solution. Things are of course more complicated in larger dimensions (Tibshirani &#38; Wasserman (2016) goes back at length on the geometry of the solutions) but as Candès &#38; Plan (2009) notes, under minimal assumptions guaranteeing that the predictors are not strongly correlated, the Lasso obtains a quadratic error almost as good as if we had an oracle providing perfect information on the set of [latex]\beta_j[/latex]'s that are not zero. With some additional technical hypotheses, it can be shown that this estimator is "sparsistant" in the sense that the support of [latex]\widehat{\beta}_\lambda^{\text{lasso}}[/latex] is that of [latex]\beta[/latex], in other words Lasso has made it possible to select variables (more discussions on this point can be obtained in Hastie et al. (2016)).More generally, it can be shown that [latex]\widehat{\beta}_\lambda^{\text{lasso}}[/latex] is a biased estimator, but may be of sufficiently low variance that the mean square error is lower than using least squares. To compare the three techniques, relative to the least square estimator (obtained when [latex]\lambda=0[/latex]), if we assume that the explanatory variables are orthonormal, then [latex display="true"]\widehat{\beta}_{\lambda,j}^{\text{ subset}}=\widehat{\beta}_{j}^{\text{ ols}}\boldsymbol{1}_{|\widehat{\beta}_{\lambda,j}^{\text{ subset}}|&#62;b}, ~~\widehat{\beta}_{\lambda,j}^{\text{ ridge}}=\frac{\widehat{\beta}_{j}^{\text{ ols}}}{1+\lambda}[/latex]and[latex display="true"]\widehat{\beta}_{\lambda,j}^{\text{ lasso}}=\text{sign}[\widehat{\beta}_{j}^{\text{ ols}}]\cdot(|\widehat{\beta}_{j}^{\text{ ols}}|-\lambda)_+[/latex]Figure 3 : Penalization based on norms ,  and  (from Hastie et al. (2016)).To be continued with probably a final post this week (references are online here)…