← Notes · December 2026

Collinearity and geographically weighted regression: some theory

Variance inflation, what removing a correlated predictor does to the others, log-scale interpretation, and the bias–variance tradeoff of geographically weighted regression, with proofs.

Public health data at the level of states or counties raise two recurring problems. Risk factors such as age, obesity, hypertension and cardiovascular disease are strongly correlated, so their separate effects are hard to estimate. And the effect of a risk factor may differ from place to place. A common workflow removes collinear predictors by their variance inflation factor (VIF), then fits a geographically weighted regression (GWR) to let coefficients vary in space. These notes collect the mathematics behind both steps.

1. Variance inflation

Consider \(y = X\beta + \varepsilon\) with an intercept, \(n\) observations and \(p\) predictors, \(\mathbb E\varepsilon = 0\), \(\operatorname{Var}\varepsilon = \sigma^2 I\). Let \(R_j^2\) be the \(R^2\) from regressing predictor \(x_j\) on the other predictors, and \(S_{jj} = \sum_i (x_{ij}-\bar x_j)^2\).

Proposition 1. The least-squares estimator satisfies \[ \operatorname{Var}(\hat\beta_j \mid X) = \frac{\sigma^2}{S_{jj}\,(1-R_j^2)} = \frac{\sigma^2}{S_{jj}}\cdot\mathrm{VIF}_j, \qquad \mathrm{VIF}_j = \frac{1}{1-R_j^2}. \]

Proof. By the Frisch–Waugh–Lovell theorem, \(\hat\beta_j = \tilde x_j^\top y / \tilde x_j^\top\tilde x_j\), where \(\tilde x_j\) is the residual from regressing \(x_j\) on the intercept and the other predictors. Hence \(\operatorname{Var}(\hat\beta_j\mid X) = \sigma^2/\|\tilde x_j\|^2\). By definition of \(R_j^2\), \(\|\tilde x_j\|^2 = (1-R_j^2)\,S_{jj}\). \(\square\)

So \(\mathrm{VIF}_j\) is exactly the factor by which collinearity inflates the variance of \(\hat\beta_j\), compared with a predictor uncorrelated with the others. The common threshold \(\mathrm{VIF}=10\) means \(R_j^2 = 0.9\): about 90% of \(x_j\) is explained by the other predictors.

Proposition 2. Let \(C\) be the \(p\times p\) correlation matrix of the predictors. Then \(\mathrm{VIF}_j = (C^{-1})_{jj}\).

Proof. Standardise the predictors, so \(C = Z^\top Z/(n-1)\). Partition \(C\) with \(x_j\) first: \(C = \begin{pmatrix}1 & c^\top\\ c & C_{-j}\end{pmatrix}\). By the block inverse formula, \((C^{-1})_{jj} = 1/(1 - c^\top C_{-j}^{-1}c)\). For standardised variables, \(c^\top C_{-j}^{-1}c\) is the \(R^2\) of regressing \(x_j\) on the others, that is, \(R_j^2\). \(\square\)

2. What removing a predictor does

Removing the predictor with the largest VIF reduces variance, but it changes what the remaining coefficients mean.

Proposition 3 (omitted variables). Split \(X = [X_1\ X_2]\) and \(\beta = (\beta_1,\beta_2)\), and fit the short model with \(X_1\) only. Then \[ \mathbb E\big[\hat\beta_1^{\text{short}} \mid X\big] = \beta_1 + \Gamma\,\beta_2, \qquad \Gamma = (X_1^\top X_1)^{-1}X_1^\top X_2 . \]

Proof. \(\hat\beta_1^{\text{short}} = (X_1^\top X_1)^{-1}X_1^\top y\). Substitute \(y = X_1\beta_1 + X_2\beta_2 + \varepsilon\) and take expectations. \(\square\)

The columns of \(\Gamma\) are the coefficients from regressing each removed predictor on the retained ones. When obesity is retained and hypertension removed, the obesity coefficient estimates its own effect plus the part of the hypertension effect that runs through their correlation. The retained predictor becomes a proxy for its correlated group, and its coefficient should be read that way.

Remark (which variable survives). When two predictors are nearly duplicates, both have large VIFs of similar size, and small changes in the data decide which one is removed. In a simulation with correlated age, obesity and hypertension (true effect on obesity only), VIF removal dropped obesity and kept hypertension, whose coefficient then carried the obesity effect. The conclusion "the retained variable matters" is robust; "the removed variable does not" is not.

3. Working on the log scale

Rates are often skewed, so the response is modelled as \(\log y = x^\top\beta + \varepsilon\).

Proposition 4. In the log-linear model, increasing \(x_j\) by one unit, with the others fixed, multiplies the conditional median of \(y\) by \(e^{\beta_j}\). If \(\varepsilon\sim\mathcal N(0,\sigma^2)\) independently of \(x\), the conditional mean is \[ \mathbb E[y\mid x] = \exp\!\big(x^\top\beta + \tfrac12\sigma^2\big). \]

Proof. The median of \(\varepsilon\) is 0 and \(\exp\) is increasing, so the median of \(y\) is \(\exp(x^\top\beta)\), and the ratio of medians at \(x_j+1\) and \(x_j\) is \(e^{\beta_j}\). For the mean, \(\mathbb E[e^\varepsilon] = e^{\sigma^2/2}\) is the moment generating function of \(\mathcal N(0,\sigma^2)\) at 1. \(\square\)

So \(100(e^{\beta_j}-1)\%\) is the percentage change per unit of \(x_j\), and simply exponentiating fitted values underestimates the mean by the factor \(e^{\sigma^2/2}\) (the retransformation bias).

4. Geographically weighted regression

Definition. Let unit \(i\) have location \(u_i\), a kernel \(K\ge0\) and bandwidth \(h>0\). At a location \(u\), set \(w_i(u) = K\big(d(u,u_i)/h\big)\) and \(W(u) = \operatorname{diag}(w_i(u))\). The GWR estimate is the weighted least-squares fit \[ \hat\beta(u) = \arg\min_\beta \sum_i w_i(u)\,(y_i - x_i^\top\beta)^2 = \big(X^\top W(u) X\big)^{-1} X^\top W(u)\, y . \]
Proposition 5 (the global limit). If \(K\) is continuous at 0 with \(K(0)>0\), then as \(h\to\infty\), \(\hat\beta(u)\) converges to the ordinary least-squares estimate \((X^\top X)^{-1}X^\top y\) at every \(u\).

Proof. As \(h\to\infty\), each \(w_i(u)\to K(0)\), so \(W(u)\to K(0)\,I\). The constant \(K(0)\) cancels in \((X^\top WX)^{-1}X^\top Wy\), and the map is continuous wherever \(X^\top X\) is invertible. \(\square\)

Proposition 6 (the price of flexibility). If the true coefficients do not vary in space (\(y = X\beta+\varepsilon\) with constant \(\beta\)), then \(\hat\beta(u)\) is unbiased for every \(u\) and \(h\), and \[ \operatorname{Var}\big(\hat\beta(u)\mid X\big) \;\succeq\; \sigma^2 (X^\top X)^{-1}, \] in the sense of positive semidefinite matrices.

Proof. \(\hat\beta(u) = \beta + (X^\top WX)^{-1}X^\top W\varepsilon\), so it is unbiased. It is a linear unbiased estimator of \(\beta\), and by the Gauss–Markov theorem ordinary least squares has the smallest variance among those, in the positive semidefinite order. \(\square\)

So when nothing varies in space, GWR can only add variance. Its benefit appears when coefficients do vary: then a global fit is biased, and local fits trade that bias for variance. The bandwidth controls the trade.

Proposition 7 (effective sample size). For weights \(w_1,\dots,w_n\ge0\), not all zero, let \[ n_{\text{eff}} = \frac{\big(\sum_i w_i\big)^2}{\sum_i w_i^2}. \] Then \(1\le n_{\text{eff}}\le n\), with \(n_{\text{eff}}=n\) if and only if all weights are equal. If the \(y_i\) are independent with variance \(\sigma^2\), the weighted mean \(\sum_i w_iy_i/\sum_i w_i\) has variance \(\sigma^2/n_{\text{eff}}\).

Proof. By Cauchy–Schwarz, \((\sum_i w_i\cdot1)^2\le n\sum_i w_i^2\), with equality exactly when the weights are proportional to \((1,\dots,1)\). The lower bound holds because \((\sum_i w_i)^2 \ge \sum_i w_i^2\) for non-negative weights. The variance is \(\sigma^2\sum_i w_i^2/(\sum_i w_i)^2\). \(\square\)

With 30 to 50 states, this matters. A simulation with 48 locations and a coefficient that changes smoothly in space gives:

BandwidthMedian \(n_{\text{eff}}\)Error in local coefficient (RMSE)
Narrow9.50.091
Medium24.80.101
Very wide (≈ OLS)48.00.246

A very wide bandwidth misses the spatial variation entirely (Proposition 5). A narrow one tracks it, but each local fit rests on about ten effective states, so individual local coefficients are noisy. In practice the bandwidth is chosen by cross-validation or a corrected AIC, and local estimates are best read as smooth patterns, not state-by-state values.

5. Implementation

A Python version of VIF removal and a fixed-bandwidth Gaussian-kernel GWR, tested on synthetic data (it reproduces the table above, and \((C^{-1})_{jj}\) matches \(1/(1-R_j^2)\) as in Proposition 2):

import numpy as np

def vif(X):
    """VIF_j = (C^{-1})_jj, C = predictor correlation matrix (Proposition 2)."""
    return np.diag(np.linalg.inv(np.corrcoef(X, rowvar=False)))

def drop_by_vif(X, names, thresh=10.0):
    names = list(names)
    while X.shape[1] > 1:
        v = vif(X)
        if v.max() < thresh:
            break
        j = int(np.argmax(v))
        X = np.delete(X, j, axis=1); names.pop(j)
    return X, names

def gwr(coords, X, y, h):
    """Local weighted least squares, Gaussian kernel, fixed bandwidth h.
    Returns local coefficients (intercept first) and effective sample sizes."""
    n = len(y); X1 = np.column_stack([np.ones(n), X]); B, neff = [], []
    for i in range(n):
        d = np.linalg.norm(coords - coords[i], axis=1)
        w = np.exp(-0.5 * (d / h) ** 2)
        XtW = X1.T * w
        B.append(np.linalg.solve(XtW @ X1, XtW @ y))
        neff.append(w.sum() ** 2 / (w ** 2).sum())
    return np.array(B), np.array(neff)

In R, car::vif() computes VIFs, and the spgwr and GWmodel packages fit GWR with bandwidth selection.

6. An application

We used this workflow to study how COVID-19 risk factors differed across ethnic groups in the United States during the first wave of the pandemic, using state-level data. After removing collinear predictors, poverty remained an independent predictor of mortality for Non-Hispanic White, Non-Hispanic Black and Hispanic populations. For the White and Black populations, obesity absorbed the effects of age, hypertension and cardiovascular disease, as Proposition 3 describes, and age was the strongest predictor of mortality among Hispanics. GWR showed that the coefficients varied from state to state. Details are in Kumar et al. (2021).

Exercises

  1. For two predictors with correlation \(\rho\), show that \(\mathrm{VIF}_1 = \mathrm{VIF}_2 = 1/(1-\rho^2)\). Which correlation corresponds to the threshold \(\mathrm{VIF}=10\)?
    Show answer

    With one other predictor, \(R_1^2 = \rho^2\), so \(\mathrm{VIF}_1 = 1/(1-\rho^2)\), and the same for \(x_2\). Equivalently, \(C^{-1} = \frac{1}{1-\rho^2}\begin{pmatrix}1&-\rho\\-\rho&1\end{pmatrix}\). Setting \(1/(1-\rho^2) = 10\) gives \(\rho^2 = 0.9\), so \(|\rho|\approx0.949\). The threshold only removes predictors that are very strongly correlated; moderate correlations still inflate variances, just less.

  2. Suppose \(y = \beta_1x_1 + \beta_2x_2 + \varepsilon\), where \(x_1, x_2\) have standard deviations \(s_1, s_2\) and correlation \(\rho\). If \(x_2\) is removed, what does \(\hat\beta_1\) estimate? When is the bias zero?
    Show answer

    By Proposition 3 with one retained and one removed predictor, \(\Gamma = \operatorname{Cov}(x_1,x_2)/\operatorname{Var}(x_1) = \rho s_2/s_1\), so \(\hat\beta_1\) estimates \(\beta_1 + \beta_2\rho\, s_2/s_1\). The bias is zero only if \(\beta_2 = 0\) or \(\rho = 0\). If both effects are positive and the predictors are positively correlated, the retained coefficient overstates its own effect.

  3. Compute \(n_{\text{eff}}\) for the weights \((1, \tfrac12, \tfrac12, \tfrac14)\). Then show that a Gaussian kernel with bandwidth \(h\) much smaller than the distance between units gives \(n_{\text{eff}}\approx1\) at each unit. What happens to GWR then?
    Show answer

    \(n_{\text{eff}} = (2.25)^2/(1 + 0.25 + 0.25 + 0.0625) = 5.0625/1.5625 = 3.24\). If \(h\) is much smaller than the distances, \(w_i(u_i) = K(0)\) while all other weights are nearly 0, so \(n_{\text{eff}}\to1\). Then \(X^\top W(u_i)X\) is nearly rank one, and with more than one coefficient the local fit is close to singular: GWR tries to fit \(p\) coefficients from about one observation. This is why bandwidths are chosen by cross-validation, which rules out such fits.

References