Why Dependence Changes Standard Errors
In spatial and network data, nearby locations or connected units may experience related shocks. Even when a regression coefficient is consistently estimated, treating all observations as independent can misstate its uncertainty. Spatial and network heteroskedasticity-and-autocorrelation-consistent (HAC) estimators address this by incorporating weighted products of regression scores for pairs of observations.
These estimators change the estimated covariance matrix, not the regression coefficients. They do not make an endogenous regressor exogenous, remove omitted-variable bias, or establish a causal interpretation. The regression model and the dependence assumptions supporting inference must be considered separately.
A standard starting point is the linear conditional-mean restriction \(E[u_i\mid X]=0\), where \(X\) denotes the regressor data, together with a nonsingular probability limit for \(\hat Q\). For consistency of the coefficient estimator, suitable sampling and dependence conditions are also needed; robust covariance estimation alone does not guarantee consistency. The dependence-robust covariance targets uncertainty around a coefficient estimator that is valid under the model and asymptotic framework being used.
From Regression Scores to a Covariance Estimate
The score contribution for observation \(i\) in the least-squares moment equation is \(x_i u_i\). The OLS estimation error satisfies the exact identity
For a fixed design, the covariance of the average score is
This expression includes both the variance terms \(i=j\) and any cross-observation covariance terms \(i\ne j\). In an estimator, the unknown disturbances are replaced by residuals, and the cross-products are weighted to reflect which pairs may be dependent. The two factors of \(n\) in the denominator matter: this formula estimates the covariance of \(\hat\beta\), not the asymptotic covariance of \(\sqrt n(\hat\beta-\beta)\).
The weights should be symmetric, \(w_{ij}=w_{ji}\), and usually include the diagonal, with \(w_{ii}=1\). Summing over all ordered pairs then produces a symmetric meat matrix. The resulting estimate can nevertheless fail to be positive semidefinite for some weight choices or samples; a negative estimated variance for a contrast signals a problem requiring investigation, not a valid standard error.
Distance-Based Spatial HAC
For spatial observations, let \(s_i\) denote the location of unit \(i\), and let \(d_{ij}\) be a specified distance between \(s_i\) and \(s_j\), such as Euclidean or great-circle distance. A spatial HAC weight can take the form \(w_{ij}=K(d_{ij}/h_n)\), where \(K\) is a kernel and \(h_n\) is a bandwidth. A common compact-support choice is the Bartlett taper \(K(r)=\max(1-r,0)\). It gives full weight to a unit's own score and gradually reduces the weight on score products as the separation approaches the bandwidth.
Spatial HAC is justified when disturbances or regression scores may be correlated across nearby locations, while dependence between sufficiently distant locations is negligible or declines sufficiently fast. A typical framework is increasing-domain asymptotics: the observed region expands as \(n\) grows, dependence is weak enough for the relevant covariance sums to be controlled, and the bandwidth grows to include more nearby pairs while remaining small relative to the spatial domain. Precise sufficient conditions depend on the sampling design, distance metric, kernel, and dependence process. A bandwidth is not a substitute for a defensible account of how dependence decays.
Worked Example: A Spatial HAC Standard Error for an Intercept
Consider a hypothetical regression with an intercept only, \(y_i=\beta+u_i\), at three sites on a line. The fitted residuals are \((-1,0,1)\), so they sum to zero as required by OLS with an intercept. The distances between consecutive sites are 1, and the distance between the first and third sites is 2. Use a Bartlett weight with bandwidth \(h_n=2\), so \(w_{ij}=\max(1-d_{ij}/2,0)\).
The diagonal weights are 1, the two consecutive-site weights are \(1-1/2=0.5\), and the weight between the first and third sites is 0. The intercept regressor is \(x_i=1\), so \(\hat Q=n^{-1}\sum_i 1=1\). The weighted residual-product sum, including ordered pairs, is
Thus the covariance estimate for the intercept is
This is a hypothetical standard error in the units of the outcome. The calculation assumes that the chosen distance and bandwidth are appropriate for representing relevant spatial dependence; three observations alone do not establish that assumption.
Graph-Based Network-Robust Covariance
For network observations, represent the specified links by a graph and let \(d^G_{ij}\) be the shortest-path distance between nodes \(i\) and \(j\). A graph-based HAC estimator uses weights determined by this distance. For example, \(w_{ij}=\lambda^{d^G_{ij}}\), for \(0<\lambda<1\), assigns decreasing weight to score products for nodes farther apart. Disconnected node pairs can be assigned weight zero. Another option is to retain pairs only up to a chosen graph-distance radius.
This approach requires a substantive assumption: the graph must capture the pathways through which relevant score dependence travels. It is often motivated by local network dependence, where dependence is strongest among linked units or units connected by short paths and weakens with graph distance. A graph-based estimator is not automatically valid merely because network data are available. For consistency, one also needs a suitable sequence of networks, enough observations for the weighted score sums to stabilize, controlled dependence as network size grows, and appropriate conditions on regressors and \(\hat Q\). If important common shocks connect distant nodes in ways the graph misses, graph-distance weights may not capture the covariance.
Worked Example: A Graph-Weighted Intercept Covariance
Suppose a hypothetical network has four nodes, with links only between nodes 1 and 2, and between nodes 3 and 4. A regression with an intercept only has residuals \((-1,-1,1,1)\), which sum to zero. Use \(w_{ii}=1\), \(w_{ij}=0.25\) for linked pairs, and zero for pairs in different connected components.
Here \(\hat Q=1\). The diagonal residual products sum to \(1+1+1+1=4\). Each linked pair has residual product 1; since the double sum includes both orders, each link contributes \(2(0.25)(1)=0.5\). The two links therefore contribute 1, giving a weighted sum of \(4+1=5\). The covariance and standard error are
The estimate has the units of the outcome squared, and its square root has the units of the outcome. The chosen weights encode a particular dependence pattern; another graph, weighting rule, or network-dependence assumption could lead to a different estimate.
Bandwidths, Clustering, and Interpretation
Spatial and network HAC estimators use a weighting rule to summarize potentially many pairwise covariances. A narrow bandwidth or graph radius can omit relevant dependence and understate uncertainty. A very broad one can add many noisy residual products, increasing estimation variability. Kernel and bandwidth choices should be reported and justified in terms of the spatial or network dependence being modeled. Sensitivity to reasonable choices is informative, but does not by itself validate the assumed dependence structure.
Cluster-robust covariance estimation instead divides observations into clusters and permits arbitrary dependence within each cluster, while relying on independence across clusters under its standard justification. Its meat is built from the outer products of cluster-level summed scores. Clustering is a natural choice when units fall into meaningful, non-overlapping groups and within-group dependence is unrestricted. HAC weighting is useful when dependence varies with physical distance or graph proximity, so a partition into independent clusters would discard meaningful relationships or impose an implausible boundary.
Neither method is universally more robust. Clustering assumes a credible cluster structure and enough independent clusters for its asymptotic justification. Spatial or network HAC assumes a credible proximity measure, a defensible decay or locality pattern, and suitable asymptotic conditions. When the dependence pattern is genuinely block-like, cluster-robust inference may be clearer. When it is graded by distance or network paths, a HAC construction can represent that structure more directly.
Worked Example: Checking the Sandwich Scaling
Consider a hypothetical regression through the origin with \(n=3\), regressors \(x=(1,2,1)\), and outcomes \(y=(3,3,3)\). OLS gives \(\hat\beta=(1\cdot3+2\cdot3+1\cdot3)/(1^2+2^2+1^2)=12/6=2\), with residuals \(\hat u=(1,-1,1)\). Suppose the spatial weighting rule retains only diagonal terms, so \(w_{ii}=1\) and \(w_{ij}=0\) for \(i\ne j\).
The regressor moment is \(\hat Q=(1/3)(1+4+1)=2\). The weighted score-product sum is \(\sum_i x_i^2\hat u_i^2=1+4+1=6\). Applying the covariance formula for \(\hat\beta\) gives
The result can also be checked directly: with diagonal weights, the scalar sandwich is \(\sum_i x_i^2\hat u_i^2/(\sum_i x_i^2)^2=6/36=1/6\). This confirms that the score-product sum is divided by \(n^2\) when \(\hat Q\) is defined with the \(1/n\) normalization.
Common Mistakes and Practical Limits
- Using the wrong scaling. Combining \(\hat Q=n^{-1}\sum_i x_ix_i'\) with an \(n^{-1}\) weighted sum estimates the asymptotic covariance on the \(\sqrt n\) scale. For the covariance of \(\hat\beta\), use \(n^{-2}\), or divide the asymptotic covariance estimate by \(n\).
- Treating a weight matrix as a dependence model. A distance taper cannot establish that distant observations are independent or that the graph captures all relevant dependence. Those claims require substantive and asymptotic justification.
- Assuming robust means unbiased or causal. HAC standard errors address estimated uncertainty under specified conditions. They do not correct endogeneity, omitted variables, invalid instruments, or misspecified spatial feedback.
- Equating proximity with clustering. Clusters are disjoint groups; distance- and graph-based dependence can cross arbitrary group boundaries and decay gradually.
After forming the covariance matrix, the standard error for coefficient \(\hat\beta_r\) is the square root of its estimated variance, the \(r\)th diagonal element. For a linear contrast \(a'\hat\beta\), its estimated variance is \(a'\widehat{\operatorname{Var}}(\hat\beta)a\). Large-sample tests and confidence intervals then require the relevant asymptotic approximation to be credible. A small number of spatial units or networks can make conventional large-sample approximations unreliable, regardless of how carefully the covariance matrix is constructed.
Check Your Understanding
Answer each question by referring to the covariance target, the dependence structure, and the stated units where relevant.
- Why does the covariance estimator for \(\hat\beta\) use \(n^{-2}\) with \(\hat Q=n^{-1}\sum_i x_ix_i'\)? What does an \(n^{-1}\) factor estimate instead?
- In a distance-based spatial HAC estimator, what roles do the distance metric, kernel, and bandwidth play?
- State one dependence assumption needed to justify graph-based network HAC, and explain why a graph alone does not guarantee that assumption.
- How does the standard cluster-robust dependence assumption differ from a distance-weighted HAC assumption?
- Do spatial HAC or network HAC standard errors remove endogeneity bias? Explain briefly.