Why Weight Observations?
Ordinary least squares gives each observation the same role in minimizing squared residuals. That is appropriate when observations have the same error variance, but not when some measurements are known to be much less precise than others. If the variance pattern is known, weighted least squares (WLS) accounts for it by giving less weight to observations with greater variance.
The weights affect how the fitted line is chosen; they do not change what a regression coefficient means. For example, a slope still describes the change in the model’s mean response associated with a one-unit increase in the predictor, with other predictors held fixed. Its interpretation is an association in the fitted mean model, not by itself a causal effect.
The Model and the Weighting Rule
For \(n\) observations, write the linear regression model as \(\mathbf{y}=\mathbf{X}\boldsymbol{\beta}+\boldsymbol{\varepsilon}\). Here \(\mathbf{y}\) is the response vector, \(\mathbf{X}\) is the design matrix, and \(\boldsymbol{\beta}\) is the vector of regression coefficients. Assume the errors are independent, have mean zero, and have known variances \(\operatorname{Var}(\varepsilon_i)=\sigma_i^2\). Thus the variance may differ across observations. The columns of \(\mathbf{X}\) must be linearly independent so the coefficients can be estimated uniquely. Normal errors are an additional assumption when using the exact normal-based confidence intervals below.
The weighting rule follows from measuring residuals in units of their standard deviations. An observation with variance \(\sigma_i^2\) has standard deviation \(\sigma_i\), so its standardized residual is \(e_i/\sigma_i\), where \(e_i=y_i-\mathbf{x}_i^{\mathsf T}\boldsymbol{\beta}\). Squaring that standardized residual gives \(e_i^2/\sigma_i^2\). WLS therefore minimizes
To obtain the estimator, differentiate this quadratic with respect to \(\boldsymbol{\beta}\) and set the derivative equal to zero:
Rearranging gives the weighted normal equations, \(\mathbf{X}^{\mathsf T}\mathbf{W}\mathbf{X}\hat{\boldsymbol{\beta}}=\mathbf{X}^{\mathsf T}\mathbf{W}\mathbf{y}\). The full-rank assumption makes \(\mathbf{X}^{\mathsf T}\mathbf{W}\mathbf{X}\) invertible, yielding the estimator in the definition. Equivalently, WLS is ordinary least squares applied to the response and design rows after each has been multiplied by \(\sqrt{w_i}=1/\sigma_i\).
The covariance result can be checked directly. The estimator is a linear transformation of \(\mathbf{y}\), so its covariance is
because \(\operatorname{Var}(\mathbf{y})=\mathbf{W}^{-1}\), and \(\mathbf{W}\mathbf{W}^{-1}\mathbf{W}=\mathbf{W}\). A coefficient’s standard error is the square root of the corresponding diagonal entry of this covariance matrix.
Worked Example: A Weighted Mean
Suppose two independent measurements of the same mean response are 10 and 14 units. Their known error variances are 1 and 4 square units, respectively. Assume the measurements have normal errors and share a common mean \(\beta_0\). This is a regression model with an intercept and no predictors.
The inverse-variance weights are \(w_1=1/1=1\) and \(w_2=1/4=0.25\). The weighted estimate of the mean is
Its variance is the reciprocal of the sum of the weights, \(1/1.25=0.8\) square units, so \(SE(\hat{\beta}_0)=\sqrt{0.8}=0.8944\) units. A 95% normal confidence interval is
Under the assumed model, the first measurement is more precise: its variance is one-quarter of the second measurement’s variance. The estimate consequently gives it four times the weight. The interval procedure uses the stated known variances; it does not estimate a common residual variance from these two observations.
Weighted Regression With Known Absolute Variances
When the variances are known in their actual units, the covariance matrix of the coefficient estimates is \((\mathbf{X}^{\mathsf T}\mathbf{W}\mathbf{X})^{-1}\), with no additional scale multiplier. Under normal errors, a coefficient estimate divided by its standard error has a standard normal distribution when its hypothesized value is correct. This gives normal-based tests and confidence intervals.
Worked Example: Fitting a Weighted Line
Consider hypothetical responses \(y=(1,3,4)\) at predictor values \(x=(0,1,2)\). Assume the line model \(E(Y_i\mid x_i)=\beta_0+\beta_1x_i\), independent normal errors, and known variances \((1,1/4,1)\) response-units squared. Thus \(\mathbf{W}=\operatorname{diag}(1,4,1)\). With an intercept and slope, the design matrix is full rank because the predictor values are not all equal.
For this design, the weighted cross-product matrix and response cross-product are
For example, the lower-right entry is \(1(0^2)+4(1^2)+1(2^2)=8\). The inverse matrix is
Multiplying by the response cross-product gives
The fitted line is \(\hat{y}=1.333+1.5x\). The estimated slope is 1.5 response units per predictor unit. In context, the model’s mean response increases by 1.5 response units for a one-unit increase in \(x\); this is an association described by the fitted line.
The slope variance is the lower-right entry of the inverse cross-product matrix, \(6/12=0.5\), so its standard error is \(\sqrt{0.5}=0.7071\) response units per predictor unit. A 95% normal confidence interval is
Under the assumed normal-error model and known variances, this interval procedure has 95% coverage over repeated samples with the same design. The residuals do not supply an additional variance estimate here: the observation variances were specified as known in absolute units.
Known Relative Variances and an Unknown Scale
Sometimes the variance pattern is known only up to a common positive scale. Write \(\operatorname{Var}(\varepsilon_i)=\sigma^2v_i\), where the positive relative variances \(v_i\) are known but \(\sigma^2\) is unknown. In that case use \(w_i=1/v_i\). The coefficient estimate has the same WLS formula, while its covariance is \(\sigma^2(\mathbf{X}^{\mathsf T}\mathbf{W}\mathbf{X})^{-1}\). Estimate the common scale by \(\hat{\sigma}^2=Q(\hat{\boldsymbol{\beta}})/(n-p)\), where \(p\) is the number of fitted coefficients and \(Q\) is the weighted sum of squared residuals. With normal errors, coefficient-based confidence intervals use a \(t\) distribution with \(n-p\) degrees of freedom. This distinction matters: known relative variances do not mean that the absolute error variances are known.
Worked Example: Estimating Uncertainty With Relative Variances
Use hypothetical responses \(y=(1,2,2,5)\) at \(x=(0,1,2,3)\), with independent normal errors and \(\operatorname{Var}(\varepsilon_i)=\sigma^2v_i\). Suppose the known relative variances are \(v=(1,1/4,1,4)\), but the common scale \(\sigma^2\) is unknown. The corresponding weights are \(w=(1,4,1,0.25)\). The intercept-and-slope design is full rank.
The weighted cross-products are
The determinant of the cross-product matrix is \((25\cdot41-27^2)/16=37/2\), so its inverse is
Therefore the fitted coefficients are
The fitted responses at \(x=0,1,2,3\) are \(77/74,140/74,203/74,266/74\). Subtracting these from the observed responses gives residuals \(-3/74,8/74,-55/74,104/74\). Thus the weighted residual sum of squares is
There are \(n-p=4-2=2\) residual degrees of freedom, giving \(\hat{\sigma}^2=1.095/2=0.5475\). The slope’s variance estimate is \(\hat{\sigma}^2\) times the lower-right entry of the inverse cross-product matrix:
For a 95% interval, \(t_{0.975,2}\) is approximately 4.303. The resulting interval is \(0.8514\pm4.303(0.4301)=[-1.000,\,2.703]\) response units per predictor unit, to rounding. It is wide because only two residual degrees of freedom remain. Under the stated model, it is an interval for the slope in the mean response, not a range containing 95% of individual responses.
When WLS Helps—and a Common Mistake
WLS can improve precision when the variance pattern is correctly specified: observations with smaller error variance contain more information about the mean and receive greater weight. Its coefficient estimates and standard errors rely on the variance model as well as on the mean model. A wrong mean structure, such as an omitted predictor or curvature, is not repaired merely by changing weights. Likewise, WLS is not a general guarantee against all heteroskedasticity; the weights must represent the observation variances, or their relative pattern, appropriately.
- Mistake: weighting by the variance. If one observation has variance 4 times as large as another, assigning it 4 times the weight gives the less precise observation more influence. The correction is to use \(w_i=1/\sigma_i^2\), or \(1/v_i\) when variances share an unknown scale.
- Mistake: treating relative variances as absolute variances. If only \(v_i\) is known in \(\sigma^2v_i\), the common scale still has to be estimated. The coefficient covariance therefore includes \(\sigma^2\), estimated from weighted residuals.
- Mistake: interpreting the weighted slope as a different kind of effect. Weighting changes the fitted coefficient values and their precision, but the slope’s units and mean-model interpretation remain the change in fitted mean response per predictor unit.
Check Your Understanding
Use the stated variance model when answering each question.
- If one observation’s error variance is nine times another’s, what is the ratio of their inverse-variance weights?
- Why does minimizing standardized squared residuals lead to weights equal to inverse variances rather than inverse standard deviations?
- In a weighted line fit with known absolute variances and normal errors, what matrix supplies the variance of the slope estimate?
- What additional quantity must be estimated when the variances are known only as \(\sigma^2v_i\)?
- A fitted slope is 2.4 response units per predictor unit. State its mean-model interpretation without making a causal claim.