{"word_count": 1146, "character_count": 9951}
This post is the third one of our series on the history and foundations of econometric and machine learning models. Part 2 is online here.Exponential family and linear modelsThe Gaussian linear model is a special case of a large family of linear models, obtained when the conditional distribution of [latex]Y[/latex] (given the covariates) belongs to the exponential family[latex display="true"] f(y_i|\theta_i,\phi)=\exp\left(\frac{y_i\theta_i-b(\theta_i)}{a(\phi)}+c(y_i,\phi)\right) [/latex] with [latex]\theta_i=\psi(\mathbf{x}_i^T \beta)[/latex]. Functions [latex]a[/latex], [latex]b[/latex] and [latex]c[/latex] are specified according to the type of exponential law (studied extensively in statistics since Darmoix (1935), as Brown (1986) reminds us), and [latex]\psi[/latex] is a one-to-one mapping that the user must specify. Log-likelihood then has a simple expression [latex display="true"] \log\mathcal{L}(\mathbf{\theta},\phi|\mathbf{y}) =\frac{\sum_{i=1}^ny_i\theta_i-\sum_{i=1}^nb(\theta_i)}{a(\phi)}+\sum_{i=1}^n c(y_i,\phi) [/latex] and the first order condition is then written[latex display="true"] \frac{\partial \log \mathcal{L}(\mathbf{\theta},\phi|\mathbf{y})}{\partial \mathbf{\beta}} = \mathbf{X}^T\mathbf{W}^{-1}[\mathbf{y}-\widehat{\mathbf{y}}]=\mathbf{0} [/latex]based on Müller's (2011) notations, where [latex]\mathbf{W}[/latex] is a weight matrix (which depends on [latex]\beta[/latex]). Given the link between [latex]\theta[/latex] and the expectation of [latex]Y[/latex], instead of specifying the function [latex]\psi(\cdot) [/latex], we will tend to specify the link function [latex]g(\cdot)[/latex] defined by [latex display="true"]\widehat{y}=m(\mathbf{x})=\mathbb{E}[Y|\mathbf{X}=\mathbf{x}]=g^{-1} (\mathbf{x}^T \beta) [/latex]For the Gaussian linear regression we consider an identity link, while for the Poisson regression, the natural link (called canonical) is the logarithmic link. Here, as [latex]\mathbf{W}[/latex] depends on [latex]\beta[/latex] (with [latex]\mathbf{W}=diag(\nabla g(\widehat{\mathbf{y}})Var[\mathbf{y}])[/latex] there is generally no explicit formula for the maximum likelihood estimator. But an iterative algorithm makes it possible to obtain a numerical approximation. By setting [latex display="true"]\mathbf{z}=g(\widehat{\mathbf{y}})+(\mathbf{y}-\widehat{\mathbf{y}})\cdot\nabla g(\widehat{\mathbf{y}})[/latex] corresponding to the error term of a Taylor development in order 1 of [latex]g[/latex], we obtain an algorithm of the form[latex display="true"]\widehat{\beta}_{k+1}=[\mathbf{X}^T \mathbf{W}_k^{-1} \mathbf{X}]^{-1} \mathbf{X}^T \mathbf{W}_k^{-1} \mathbf{z}_k[/latex]By iterating, we will define [latex]\widehat{\beta}=\widehat{\beta}_{\infty}[/latex], and we can show that - with some additional technical assumptions (detailed in Müller (2011)) - this estimator is asymptotically Gaussian, with [latex display="true"]\sqrt{n}(\widehat{\beta} -\beta)\overset{\mathcal{L}}{\rightarrow} \mathcal{N}(\mathbf{0},I(β)^{-1}) [/latex]where numerically [latex]I(\beta)=\varphi\cdot[\mathbf{X}^T \mathbf{W}_\infty^{-1} \mathbf{X}] [/latex].From a numerical point of view, the computer will solve the first-order condition, and actually, the law of [latex]Y[/latex] does not really intervene. For example, one can estimate a "Poisson regression" even when observations are not integers (but they need to be positive). In other words, the law of [latex]Y[/latex] is only an interpretation here, and the algorithm could be introduced in a different way (as we will see later on), without necessarily having an underlying probabilistic model.Logistic RegressionLogistic regression is the generalized linear model obtained with a Bernoulli's law, and a link function which is the quantile function of a logistic law (which corresponds to the canonical link in the sense of the exponential family). Taking into account the form of Bernoulli's law, econometrics proposes a model for [latex]y_i\in\{0,1\}[/latex], in which the logarithm of the odds follows a linear model: [latex display="true"] \log\left(\frac{\mathbb{P}[Y=1\vert \mathbf{X}=\mathbf{x}]}{\mathbb{P}[Y\neq 1\vert \mathbf{X}=\mathbf{x}]}\right)=\beta_0+\mathbf{x}^T\beta [/latex]or [latex display="true"]\mathbb{E}[Y|\mathbf{X}=\mathbf{x}]=\mathbb{P}[Y=1|\mathbf{X}=\mathbf{x}]=\frac{e^{\beta_0+\mathbf{x}^T\beta}}{1+ e^{\beta_0+\mathbf{x}^T\beta}}=H(\beta_0+\mathbf{x}^T\beta) [/latex]where [latex]H(\cdot)=\exp(\cdot)/(1+exp(\cdot))[/latex] is the cumulative distribution function of the logistic law. The estimation of [latex](\beta_0,\beta) [/latex] is performed by maximizing the likelihood: [latex display="true"] \mathcal{L}=\prod_{i=1}^n \left(\frac{e^{\mathbf{x}_i^T\mathbf{\beta}}}{1+e^{\boldsymbol{x}_i^T\mathbf{\beta}}}\right)^{y_i}\left(\frac{1}{1+e^{\mathbf{x}_i^T\mathbf{\beta}}}\right)^{1-y_i} [/latex] It is said to be a linear models because isoprobability curves here are the parallel hyperplanes [latex]b+\mathbf{x}^T\beta [/latex]. Rather than this model, popularized by Berkson (1944), some will prefer the probit model (see Berkson, 1951), introduced by Bliss (1934). In this model: [latex display="true"]\mathbb{E}[Y|\mathbf{X}=\mathbf{x}]=\mathbb{P}[Y=1|\mathbf{X}=\mathbf{x}]=\Phi (\beta_0+\mathbf{x}^T\beta) [/latex]where [latex]\Phi[/latex] denotes the distribution function of the reduced centred normal distribution. This model has the advantage of having a direct link with the Gaussian linear model, since [latex]y_i=\mathbf{1}(y_i^\star&#62;0) [/latex] with [latex]y_i^\star=\beta_0+\mathbf{x}^T \beta+\varepsilon_i[/latex] where the residuals are Gaussian, [latex]\mathcal{N}(0,\sigma^2)[/latex]. An alternative is to have centered residuals of unit variance, and to consider a latent modeling of the form [latex]y_i=\mathbf{1}(y_i^\star&#62;\xi)[/latex] (where [latex] \xi[/latex] will be fixed). As we can see, these techniques are fundamentally linked to an underlying stochastic model. In the body of the article, we present several alternative techniques - from the learning literature - for this classification problem (with two classes, here [latex]0[/latex] and [latex]1[/latex]).Regression in high dimensionAs we mentioned earlier, the first order condition [latex]\mathbf{X}^T (\mathbf{X}\widehat{\beta}-\mathbf{y})=\mathbf{0}[/latex] is solved numerically by performing a QR decomposition, at a cost which consists in [latex]O(np^2) [/latex] operations (where [latex]p[/latex] is the rank of [latex]\mathbf{X}^T \mathbf{X}[/latex]). Numerically, this calculation can be long (either because [latex]p[/latex] is large or because [latex]n[/latex] is large), and a simpler strategy may be to sub-sample. Let [latex]n_s\ll n[/latex], and consider a sub-sample size [latex]n_s[/latex] of [latex]\{1,\cdots,n\}[/latex]. Then [latex]\widehat{\beta}_s=(\mathbf{X}_s^T \mathbf{X}_s )^{-1} \mathbf{X}_s^T\mathbf{y}_s[/latex] is a good approximation of [latex]\beta[/latex] as shown by Dhillon et al. (2014). However, this algorithm is dangerous if some points have a high leverage (i.e. [latex] L_i=\mathbf{x}_i(\mathbf{X}^T\mathbf{X})^{-1}\mathbf{x}_i^T[/latex]). Tropp (2011) proposes to transform the data (in a linear way), but a more popular approach is to do non-uniform sub-sampling, with a probability related to the influence of observations (defined by [latex] I_i=\widehat{\varepsilon}_iL_i/(1-L_i)^2 [/latex], and which unfortunately can only be calculated once the model is estimated).In general, we will talk about massive data when the data table of size does not fit in the RAM memory of the computer. This situation is often encountered in statistical learning nowadays with very often [latex]p\ll n[/latex]. This is why, in practice, many libraries of algorithms assimilated to machine learning use iterative methods to solve the first-order condition. When the parametric model to be calibrated is indeed convex and semi-differentiable, it is possible to use, for example, the stochastic gradient descent method as suggested by Bottou (2010). This last one allows to free oneself at each iteration from the calculation of the gradient on each observation of our learning base. Rather than making an average descent at each iteration, we start by drawing (without replacement) an observation [latex]\mathbf{x}_i[/latex] among the [latex]n[/latex] available. The model parameters are then corrected so that the prediction made from [latex]\mathbf{x}_i[/latex] is as close as possible to the true value [latex]y_i[/latex]. The method is then repeated until all the data have been reviewed. In this algorithm there is therefore as much iteration as there are observations. Unlike the gradient descent algorithm (or Newton's method) at each iteration, only one gradient vector is calculated (and no longer [latex]n[/latex]). However, it is sometimes necessary to run this algorithm several times to increase the convergence of the model parameters. If the objective is, for example, to minimize a loss function [latex]\ell[/latex] between the estimator [latex]m_\beta (\mathbf{x}) [/latex] and [latex]y[/latex] (like the quadratic loss function, as in the Gaussian linear regression) the algorithm can be summarized as follows:Step 0: Mix the dataIteration step: For [latex]t=1,\cdots, n[/latex], we pull [latex]i\in\{1,\cdots,n\}[/latex] without replacement, and we set [latex display="true"] \beta^{t+1} = \beta^{t} - \gamma_t\frac{ \partial{\ell(y_i,m_{\beta^t}(X_i)) } }{ \partial{ \beta}} [/latex]This algorithm can be repeated several times as a whole depending on the user's needs. The advantage of this method is that at each iteration, it is not necessary to calculate the gradient on all observations (more sum). It is therefore suitable for large databases. This algorithm is based on a convergence in probability towards a neighborhood of the optimum (and not the optimum itself).(references will be given in the very last post of that series) To be continued…