Tutorials › Econometrics (Graduate) › Weighted Least Squares From Known Observation Variances

Generalized Least Squares · Tutorial 145 of 952

Weighted Least Squares From Known Observation Variances

Learn how known observation variances determine weighted least squares, and work through its derivation and use in regression.

Intermediate 10 min read

What You'll Learn

  • State the regression assumptions needed for weighted least squares with known unequal variances.
  • Derive the inverse-variance objective from whitening the errors.
  • Obtain the weighted least-squares estimator and its conditional covariance matrix.
  • Calculate a weighted regression and compare it with ordinary least squares.
  • Check numerically that the whitened and weighted objectives agree.
  • Avoid common errors in interpreting weights and their assumptions.

Why Known Unequal Variances Change the Fit

In a linear regression, observations can have different error variances. If those variances are known, an observation with a larger variance is less precise than one with a smaller variance. Weighted least squares (WLS) accounts for that difference by giving each observation weight in inverse proportion to its variance. This changes the fitting criterion, not the underlying regression equation: the goal remains to estimate the same coefficient vector.

The distinction matters in applications where observation-specific precision is supplied by the measurement process or the design. WLS is not simply a way to make residuals look more uniform, and the weights are not chosen by inspecting which observations have the largest residuals. The inverse-variance rule follows from the model’s error covariance.

Model and Assumptions

Model: For observations \(i=1,\ldots,n\), let \(y=X\beta+u\), where \(y\) is an \(n\)-vector of outcomes, \(X\) is a known \(n\times k\) design matrix of full column rank, \(\beta\) is a \(k\)-vector of coefficients, and \(u\) is an \(n\)-vector of errors. Conditional on \(X\), assume \(E(u\mid X)=0\) and \(\operatorname{Var}(u\mid X)=\Omega=\operatorname{diag}(\sigma_1^2,\ldots,\sigma_n^2)\), where every \(\sigma_i^2>0\) is known. Thus errors have zero conditional means and are uncorrelated across observations; independent errors satisfy this covariance condition.

The diagonal covariance matrix is the key restriction here: the error variance may differ by observation, but there is no covariance between distinct observations. No normality assumption is required to define or calculate WLS, or to obtain its conditional covariance matrix. If the errors are also conditionally normal, the same criterion is the Gaussian likelihood criterion for \(\beta\). The variances must be treated as known for the results below; replacing them with estimates changes the problem.

Let \(D=\operatorname{diag}(\sigma_1,\ldots,\sigma_n)\). Since its diagonal entries are positive, \(D\) is invertible. Multiplying the regression by \(D^{-1}\) divides each observation by its error standard deviation. In the transformed model the error covariance is the identity matrix:

$$ D^{-1}y=D^{-1}X\beta+D^{-1}u, \qquad \operatorname{Var}(D^{-1}u\mid X) =D^{-1}\Omega D^{-1}=I_n. $$

This transformation is called whitening. It turns the unequal-variance regression into a regression with equal transformed error variances. Ordinary least squares on the transformed variables is therefore the route to WLS.

Deriving the Inverse-Variance Weights

Write \(\hat{\beta}_{WLS}\) for the WLS estimator. Ordinary least squares on the whitened equation minimizes the sum of squared transformed residuals. For a candidate coefficient vector \(b\), the transformed residual for observation \(i\) is \((y_i-x_i'b)/\sigma_i\), where \(x_i'\) is row \(i\) of \(X\). Therefore the criterion is:

$$ Q(b)=\sum_{i=1}^n\left(\frac{y_i-x_i'b}{\sigma_i}\right)^2 =\sum_{i=1}^n\frac{(y_i-x_i'b)^2}{\sigma_i^2}. $$
Definition: Weighted least squares with known observation variances minimizes the sum of squared residuals weighted by \(w_i=1/\sigma_i^2\). In matrix form, with \(W=\Omega^{-1}=\operatorname{diag}(w_1,\ldots,w_n)\), the criterion is \((y-Xb)'W(y-Xb)\).

To derive the estimator, differentiate the matrix criterion with respect to \(b\) and set the derivative to zero. Since \(W\) is symmetric, the resulting normal equations and solution are:

$$ \frac{\partial}{\partial b}\left[(y-Xb)'W(y-Xb)\right] =-2X'W(y-Xb)=0, \qquad \hat{\beta}_{WLS}=(X'WX)^{-1}X'Wy. $$

The inverse exists because \(X\) has full column rank and \(W\) is positive definite: for any nonzero \(a\), \(a'X'WXa=(Xa)'W(Xa)>0\). This also ensures the criterion has a unique minimum. Multiplying all weights by the same positive constant does not change the estimator: the common factor appears in both \(X'WX\) and \(X'Wy\) and cancels. But the relative weights matter. One must not confuse the regression weights \(1/\sigma_i^2\) with the divisors \(1/\sigma_i\) used to transform individual observations.

Properties of the Estimator

Because \(\hat{\beta}_{WLS}\) is a linear function of \(y\), its expectation and conditional covariance follow directly from the model:

$$ E(\hat{\beta}_{WLS}\mid X)=\beta, \qquad \operatorname{Var}(\hat{\beta}_{WLS}\mid X) =(X'WX)^{-1}. $$

For the covariance calculation, set \(A=(X'WX)^{-1}X'W\), so that \(\hat{\beta}_{WLS}=Ay\). Then \(\operatorname{Var}(Ay\mid X)=A\Omega A'\). Substituting \(W=\Omega^{-1}\), and using the symmetry of \(W\), gives:

$$ A\Omega A' =(X'WX)^{-1}X'W\Omega WX(X'WX)^{-1} =(X'WX)^{-1}, $$

because \(W\Omega W=W\). Thus, when the variances are known, this covariance matrix does not require an estimate of a common error variance. Under the stated zero-mean and covariance assumptions, WLS is the best linear unbiased estimator: among linear unbiased estimators, it has the smallest covariance matrix in the positive-semidefinite ordering. This is the GLS efficiency result for the diagonal covariance matrix \( \Omega \).

The covariance result does not by itself assert that the coefficient estimates are normally distributed. Conditional normality of the errors gives normal coefficient estimates and supports exact normal-theory inference using the known covariance matrix. Without that distributional assumption, unbiasedness and the covariance expression still hold, but exact finite-sample normal inference does not follow automatically.

Worked Example: Estimating a Common Mean

Suppose three independent measurements of one common quantity have values \(10\), \(14\), and \(12\) units, with known error variances \(1\), \(4\), and \(1\) squared units. Assume each measurement has that common mean and a zero-mean error. The intercept-only design has one column of ones, so the WLS estimate is the weighted mean.

The weights are the inverse variances: \(1\), \(1/4\), and \(1\). Thus:

$$ \hat{\beta}_{WLS} =\frac{1(10)+(1/4)(14)+1(12)}{1+1/4+1} =\frac{25.5}{2.25} =11.33\text{ units}. $$

The second measurement is less precise, so it contributes less to the estimate. For comparison, the unweighted mean is \((10+14+12)/3=12.00\) units. The conditional variance of the weighted estimate is the reciprocal of the sum of the weights, \(1/2.25=0.4444\) squared units, giving a standard error of \(\sqrt{0.4444}=0.6667\) units. These calculations use the stated known variances; they do not estimate a residual variance from the three measurements.

Weighted Regression With Unequal Known Variances

For a regression with an intercept and one predictor, the WLS criterion is the sum of each squared residual multiplied by its inverse error variance. In the next example, the observations with larger known variances are deliberately given less influence. The variances are part of the hypothetical setup, not estimates obtained from this small data set.

Worked Example: A Regression With Three Different Variances

Consider the hypothetical observations below, with a known error variance for each outcome. Fit \(y_i=\beta_0+\beta_1x_i+u_i\), assuming \(E(u\mid X)=0\), independent errors, the stated variances, and a design matrix of full column rank.

Observation\(x_i\)\(y_i\)Known variance \(\sigma_i^2\)Weight \(w_i\)
10111
21441/4
32291/9

With an intercept, each row of \(X\) is \((1,x_i)\). The weighted cross-products and outcome products are:

$$ X'WX= \begin{pmatrix} 49/36 & 17/36\\ 17/36 & 25/36 \end{pmatrix}, \qquad X'Wy= \begin{pmatrix} 20/9\\ 13/9 \end{pmatrix}. $$

Solving \((X'WX)\hat{\beta}_{WLS}=X'Wy\) gives:

$$ \hat{\beta}_{WLS} = \begin{pmatrix} 31/26\\ 33/26 \end{pmatrix} \approx \begin{pmatrix} 1.192\\ 1.269 \end{pmatrix}. $$

The fitted line is \(\hat{y}=1.192+1.269x\). Its intercept is in the units of \(y\), and its slope is in units of \(y\) per unit of \(x\). For comparison, ordinary least squares on these same observations gives slope \(0.500\) and intercept \(1.833\). The estimates differ because WLS gives the observation with variance \(9\) less weight than the observations with variance \(1\); it is not because the regression equation or target coefficient changed.

For these known variances, the conditional coefficient covariance matrix is:

$$ (X'WX)^{-1} = \begin{pmatrix} 17/18 & -1/2\\ -1/2 & 1/2 \end{pmatrix}. $$

For example, the standard error of the slope under the model is \(\sqrt{1/2}=0.7071\) in units of \(y\) per unit of \(x\). Its interpretation as an exact normal-theory standard error requires conditionally normal errors; the variance calculation itself uses the specified covariance matrix.

Checking the Whitening Calculation

The weighted and whitened formulations are two expressions of the same calculation. Dividing each outcome and each design row by \(\sigma_i\) produces ordinary least squares on transformed data. The example below checks this equivalence using the fitted regression just calculated.

Worked Example: Verifying the Weighted Objective After Whitening

For the three observations above, the standard deviations are \(1\), \(2\), and \(3\). The transformed outcomes \(y_i/\sigma_i\) are \(1\), \(2\), and \(2/3\); the transformed design rows \((1,x_i)/\sigma_i\) are \((1,0)\), \((1/2,1/2)\), and \((1/3,2/3)\). The weighted fit has coefficients \(31/26\) and \(33/26\).

The untransformed residuals are \(-5/26\), \(20/13\), and \(-45/26\). Dividing each residual by its standard deviation gives the transformed residuals \(-5/26\), \(10/13\), and \(-15/26\). Their squared sum is:

$$ \left(-\frac{5}{26}\right)^2+ \left(\frac{10}{13}\right)^2+ \left(-\frac{15}{26}\right)^2 =\frac{25+400+225}{676} =\frac{25}{26} \approx0.9615. $$

Computing the original residuals with weights \(1\), \(1/4\), and \(1/9\) gives exactly the same objective:

$$ \left(-\frac{5}{26}\right)^2+ \frac{1}{4}\left(\frac{20}{13}\right)^2+ \frac{1}{9}\left(-\frac{45}{26}\right)^2 =\frac{25}{26}. $$

The agreement follows generally because \((y_i-x_i'b)^2/\sigma_i^2\) is the square of the corresponding transformed residual. The weighted fit therefore minimizes precisely the ordinary sum of squared residuals in the whitened regression.

Common Mistakes and Practical Limits

  • Using variance instead of inverse variance. Giving more weight to larger variances reverses the precision adjustment. The objective uses \(w_i=1/\sigma_i^2\), while whitening divides by \(\sigma_i\).
  • Assuming WLS repairs a misspecified mean model. WLS changes how observations contribute to fitting; it does not fix omitted variables, incorrect functional form, or a nonzero conditional error mean.
  • Treating estimated variances as known. The calculations here rely on observation variances supplied as known. Estimating a variance function and constructing feasible weights requires additional methods and uncertainty considerations.
  • Assuming unequal variances alone imply independent errors. The diagonal covariance model also rules out cross-observation covariance. If errors are correlated, inverse variances alone do not describe the full covariance adjustment.
  • Believing any positive weights have the same justification. A common positive rescaling leaves the coefficient estimate unchanged, but changing relative weights changes the estimator. The inverse-variance choice is justified by the stated covariance model.

Known-variance WLS is useful when the precision differences are substantively supported and the covariance assumptions are credible. Its value is not that it guarantees a better-looking regression, but that it uses the supplied error information to obtain the appropriate linear unbiased estimator under the model.

Check Your Understanding

Answer each question using the model assumptions and calculations in this tutorial.

  1. If an observation has error variance \(16\) and another has variance \(4\), what is the ratio of their WLS weights?
  2. Why does whitening divide by the standard deviation rather than by the variance?
  3. State the conditional covariance matrix of the WLS coefficient estimator when the variances are known.
  4. Would multiplying every WLS weight by 10 change the coefficient estimates? Explain briefly.
  5. What additional assumption would support exact normal-theory inference for the coefficients in a finite sample?
Clinical Biostats