← Notes · December 2026
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.
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\).
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.
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\)
Removing the predictor with the largest VIF reduces variance, but it changes what the remaining coefficients mean.
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.
Rates are often skewed, so the response is modelled as \(\log y = x^\top\beta + \varepsilon\).
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).
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\)
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.
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:
| Bandwidth | Median \(n_{\text{eff}}\) | Error in local coefficient (RMSE) |
|---|---|---|
| Narrow | 9.5 | 0.091 |
| Medium | 24.8 | 0.101 |
| Very wide (≈ OLS) | 48.0 | 0.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.
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.
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).
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.
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.
\(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.