Generalized Least Squares

1 view
Skip to first unread message

Idara Viengxay

unread,
Aug 4, 2024, 3:24:36 PM8/4/24
to dramruedeispid
Instatistics, generalized least squares (GLS) is a method used to estimate the unknown parameters in a linear regression model. It is used when there is a non-zero amount of correlation between the residuals in the regression model. GLS is employed to improve statistical efficiency and reduce the risk of drawing erroneous inferences, as compared to conventional least squares and weighted least squares methods. It was first described by Alexander Aitken in 1935.[1]

It requires knowledge of the covariance matrix for the residuals. If this is unknown, estimating the covariance matrix gives the method of feasible generalized least squares (FGLS). However, FGLS provides fewer guarantees of improvement.


A special case of GLS, called weighted least squares (WLS), occurs when all the off-diagonal entries of Ω are 0. This situation arises when the variances of the observed values are unequal or when heteroscedasticity is present, but no correlations exist among the observed variances. The weight for unit i is proportional to the reciprocal of the variance of the response for unit i.[2]


If the covariance of the errors Ω \displaystyle \Omega is unknown, one can get a consistent estimate of Ω \displaystyle \Omega , say Ω ^ \displaystyle \widehat \Omega ,[3] using an implementable version of GLS known as the feasible generalized least squares (FGLS) estimator.


Whereas GLS is more efficient than OLS under heteroscedasticity (also spelled heteroskedasticity) or autocorrelation, this is not true for FGLS. The feasible estimator is asymptotically more efficient (provided the errors covariance matrix is consistently estimated), but for a small to medium-sized sample, it can be actually less efficient than OLS. This is why some authors prefer to use OLS and reformulate their inferences by simply considering an alternative estimator for the variance of the estimator robust to heteroscedasticity or serial autocorrelation. However, for large samples, FGLS is preferred over OLS under heteroskedasticity or serial correlation.[3][4] A cautionary note is that the FGLS estimator is not always consistent. One case in which FGLS might be inconsistent is if there are individual-specific fixed effects.[5]


In general, this estimator has different properties than GLS. For large samples (i.e., asymptotically), all properties are (under appropriate conditions) common with respect to GLS, but for finite samples, the properties of FGLS estimators are unknown: they vary dramatically with each particular model, and as a general rule, their exact distributions cannot be derived analytically. For finite samples, FGLS may be less efficient than OLS in some cases. Thus, while GLS can be made feasible, it is not always wise to apply this method when the sample is small. A method used to improve the accuracy of the estimators in finite samples is to iterate; that is, to take the residuals from FGLS to update the errors' covariance estimator and then update the FGLS estimation, applying the same idea iteratively until the estimators vary less than some tolerance. However, this method does not necessarily improve the efficiency of the estimator very much if the original sample was small.


For simplicity, consider the model for heteroscedastic and non-autocorrelated errors. Assume that the variance-covariance matrix Ω \displaystyle \Omega of the error vector is diagonal, or equivalently that errors from distinct observations are uncorrelated. Then each diagonal entry may be estimated by the fitted residuals u ^ j \displaystyle \widehat u_j so Ω ^ O L S \displaystyle \widehat \Omega _OLS may be constructed by:


It is important to notice that the squared residuals cannot be used in the previous expression; an estimator of the errors' variances is needed. To do so, a parametric heteroskedasticity model or nonparametric estimator can be used.


The generalized least squares (GLS) estimator of the coefficients of a linear regression is a generalization of the ordinary least squares (OLS) estimator. It is used to deal with situations in which the OLS estimator is not BLUE (best linear unbiased estimator) because one of the main assumptions of the Gauss-Markov theorem, namely that of homoskedasticity and absence of serial correlation, is violated. In such situations, provided that the other assumptions of the Gauss-Markov theorem are satisfied, the GLS estimator is BLUE.


In the Gauss-Markov theorem, we make the more restrictive assumption that where is the identity matrix. The latter assumption means that the errors of the regression are homoskedastic (they all have the same variance) and uncorrelated (their covariances are all equal to zero).


The first order condition for a maximum iswhose solution isorThe second order derivative iswhich is positive definite (because is full-rank and is positive definite). Therefore, the function to be minimized is globally convex and the solution of the first order condition is a global minimum.


When the covariance matrix is diagonal (i.e., the error terms are uncorrelated), the GLS estimator is called weighted least squares estimator (WLS). In this case the function to be minimized becomeswhere is the -th entry of , is the -th row of , and is the -th diagonal element of . Thus, we are minimizing a weighted sum of the squared residuals, in which each squared residual is weighted by the reciprocal of its variance. In other words, while estimating , we are giving less weight to the observations for which the linear relationship to be estimated is more noisy, and more weight to those for which it is less noisy.


Note that we need to know the covariance matrix in order to actually compute . In practice, we seldom know and we replace it with an estimate . The estimator thus obtained, that is,is called feasible generalized least squares estimator.


There is no general method for estimating , although the residuals of a fist-step OLS regression are typically used to compute . How the problem is approached depends on the specific application and on additional assumptions that may be made about the process generating the errors of the regression.


Example A typical situation in which is estimated by running a first-step OLS regression is when the observations are indexed by time. For example, we could assume that is diagonal and estimate its diagonal elements with an exponential moving averagewhere


I'm looking to run a generalized least squares (GLS) model to replace my OLS model. I believe the residuals of the OLS model have spatial autocorrelation (I'm not positive, but the map definitely looks so). I read that GLS models correct for autocorrelation (any kind?) of residuals. I don't see GLS as an option under the Generalized Regression platform. I don't have Arc or QGIS, R, or SAS. Suggestions?


Now look at the description of "Classical Linear Mixed Model" on Mixed Models and Random Effect Models . Here is a screenshot of the formula. For such data, observations are not independent. The model allows modeling the correlation among observations.


Generalized Least Squares (GLS) estimation is a generalization of the Ordinary Least Squares (OLS) estimation technique. GLS is especially suitable for fitting linear models on data sets that exhibit heteroskedasticity (i.e., non-constant variance) and/or auto-correlation. Real world data sets often exhibit these characteristics making GLS a very useful alternative to OLS estimation.


After simplifying the above result bit (I have detailed out the simplification in this chapter), we get the following useful formula for the coefficient estimates. The following result brings out the effect of the error term ϵ on the values of the coefficients estimated by OLS:


Since the mean of error terms is assumed to be zero (a central assumption of the linear model), the elements along the main diagonal i.e. the one that extends from the top-left to the bottom-right of the above matrix containing E[(ϵ_i*ϵ_i)X] are actually the conditional variance of the error terms ϵ_i, and all non-diagonal elements E[(ϵ_i*ϵ_j)X] are the conditional covariance of error terms ϵ_i and ϵ_j.


A direct approach to fixing this issue is GLS. We start by defining a square matrix C of size [n x n] and a diagonal matrix D of size [n x n] such that the covariance matrix Ω can be expressed as a product of C, D and the transpose of C as follows:


Furthermore, the transpose of a diagonal matrix is the same matrix since the transpose operation simply flips a matrix around its main diagonal and in a diagonal matrix all non-diagonal elements are 0.


Eq (16) is an important result in the development of the GLS technique. It states that the errors of the scaled linear model are homoskedastic (i.e., constant variance) and uncorrelated. Therefore, a least squares estimator of β for this linear model will be necessarily efficient i.e. of lowest possible variance (in addition to be consistent and unbiased).


Even if the data exhibits heteroskedasticity and/or auto-correlation, the scaled (transformed) linear regression model that we have developed can be fitted using a least squares estimator that would be efficient, consistent and unbiased, in other words, it would be the Best Linear Unbiased Estimator for this model.


I am trying to do some regressions in Python using statsmodels.api, but my models all have problems with autocorrelation and heteroskedasticity. So I thought of trying out Generalized Least Squares (GLS). I am not very familiar with running this form of least squares, so stuck pretty close to the instructions on the below page:


My problem as you can probably work out by looking at the code is sigma is a very big matrix, which overloads any computer I run it on being a 50014 x 50014 matrix. But as far as I am aware the GLS matrix is meant to be big enough for every error and that is how many observations I have in my data so that is how many errors I have. So is there something I am missing about running GLS which makes the problem computationally more manageable?

3a8082e126
Reply all
Reply to author
Forward
0 new messages