# Weighted least squares to correct for heteroscedasticity

I would like to use a weighted least squares (WLS) regression to perform tests on heteroscedastic spatial data.

Each data point represents the mean of some variable over an area, and the sample sizes between the areas vary, so intuitively the things I'm measuring are more error prone in areas with a small sample size.

The variance of a mean is inversely proportional to the sample size, so presumably I should weight the regression by the inverse of this i.e. weight each point by the sample size that point was derived from.

But do I use, in this, the sample size from the dependent variable, the sample size from the independent variable - or both?

• It is good to have intuitions, but it is also good to test them where possible. I suggest plotting a) OLS residuals against sample sizes relating to the independent variable, and b) similarly for the dependent variable. It could be that your intuition is correct so far as it goes but that other sources of heteroscedasticity are also present, eg if your dependent variable is inherently non-negative and tends to have a larger variance when its conditional mean is larger. Unless theory, or your hypothesis, strongly points to a particular functional form, it is also worth considering whether ... Sep 11 '13 at 7:53
• ... a change in functional form would eliminate any heteroscedasticity. Heteroscedasticity, strictly, is a property not of data but of a model applied to a population. Sep 11 '13 at 7:59

$$\mathbf y = \mathbf X\beta + \mathbf u$$
we specify $E(\mathbf u \mid \mathbf X) = 0,\; E(\mathbf u \mathbf u'\mid \mathbf X) = \sigma^2\mathbf I$. In a heteroskedastic setting, we essentially think of conditional heteroskedasticity, namely, we assume (or suspect) that $$E(\mathbf u \mathbf u'\mid \mathbf X) = \sigma^2\mathbf \Omega$$ Since the expected value is conditional on $\mathbf X$, it will be a function of $\mathbf X$, (and not of $\mathbf y$ which is included in the error term), i.e. $\mathbf \Omega = g(\mathbf X)$. So for logical consistency, you must use characteristics related to the regressors in order to theoretically model heteroskedasticity, and then apply weighted least-squares.