Regression Methods for Geospatial DataPart 2 of 4Intermediate · Updated December 1, 2026

Kernel Regression

A neighbourhood average weights every observation inside the cutoff equally and every observation outside it at zero, so the estimate jumps as points cross the boundary. Kernel regression replaces the boundary with a weight that decreases smoothly with distance, and a prior gives the estimate a defined value where observations are sparse.

A smooth weight replaces the hard neighbourhood boundary

A neighbourhood average is a weighted average whose weights are 0 or 1:

y^(xq)=∑i1[ri≤R] yi∑i1[ri≤R]\hat{y}(\mathbf{x}_q) = \frac{\sum_i \mathbb{1}[r_i \le R]\, y_i}{\sum_i \mathbb{1}[r_i \le R]}

Replacing the indicator with any non-negative, decreasing function KK of the normalised distance rr gives the Nadaraya–Watson estimator:

y^(xq)=∑iwi yi∑iwi,wi=K ⁣(r(xq,xi))\hat{y}(\mathbf{x}_q) = \frac{\sum_i w_i\, y_i}{\sum_i w_i}, \qquad w_i = K\!\left(r(\mathbf{x}_q, \mathbf{x}_i)\right)

It is still a weighted mean, so it lies between the smallest and largest observed values: it cannot extrapolate or overshoot. This limits what it can represent and also makes it robust.

The kernel’s tail sets how far evidence reaches

Two kernels are common, and they differ mainly in the tail:

KGauss(r)=e−r2/2,KLap(r)=e−rK_{\text{Gauss}}(r) = e^{-r^2/2}, \qquad K_{\text{Lap}}(r) = e^{-r}

The Gaussian decays quickly: its weight is 3×10−43 \times 10^{-4} at r=4r = 4 and 1.5×10−81.5 \times 10^{-8} at r=6r = 6, so an observation four length scales away has effectively no influence. The exponential (Laplace) kernel, also called Matérn-12\tfrac{1}{2}, decays more slowly and keeps distant observations at a reduced weight. This suits a sparse dataset of a field with long-range structure, such as atmospheric humidity, where distant observations still carry information.

A Beta prior fills in where observations are sparse

Where the neighbourhood is empty or nearly so, ∑iwi→0\sum_i w_i \to 0 and the estimate becomes 0/00/0. Over sparsely flown regions or unused flight levels this is the normal case, not an edge case. A single distant observation also produces an estimate that looks as definite as one built on many.

The remedy is to add fictitious observations at a default value, with a total weight that expresses confidence in that default. For a probability this is a Beta prior with mean μ0\mu_0 carrying η\eta pseudo-observations: pseudo-counts ημ0\eta\mu_0 of “yes” and η(1−μ0)\eta(1-\mu_0) of “no”. Each observation adds wiyiw_i y_i to the “yes” count and wi(1−yi)w_i(1-y_i) to the “no” count, and the posterior mean is

p^(xq)=∑iwi yi+η μ0∑iwi+η\hat{p}(\mathbf{x}_q) = \frac{\sum_i w_i\, y_i + \eta\,\mu_0}{\sum_i w_i + \eta}

Three limits summarise its behaviour:

  • η→0\eta \to 0: the estimator reduces to Nadaraya–Watson.
  • η→∞\eta \to \infty: the data are ignored and p^→μ0\hat{p} \to \mu_0.
  • ∑iwi=η\sum_i w_i = \eta: data and prior have equal influence.

The last limit gives η\eta its meaning. It has the same units as the kernel weights, so it is the amount of evidence needed to move the estimate halfway from the prior: η=10\eta = 10 corresponds to ten observations located at the query point, and η=0.01\eta = 0.01 to a prior that yields to almost any data. The estimate moves smoothly between the two regimes with no special case, and as a Beta posterior mean it stays in [0,1][0,1] whenever the observations do.

μ0\mu_0 need not be constant. It can vary with the query, as a climatology or the probability a numerical weather forecast assigns to that place and time; η\eta then sets how far to trust that forecast against the observations.

Peak 0.733 at FL372Effective sample size there 3.46Moved from prior by 0.533
Figure 1.A vertical profile built one observation at a time; the dashed line is the prior and the curve the estimate. At η = 0.01 a single observation pulls the curve to its own value; at η = 10 the same observations move it little. Between nearby observations the curve interpolates rather than returning to the prior, which reasserts itself only where the kernel weights are small compared to η, for example after shrinking the vertical length scale.

Rescaled weights and a radius cutoff keep the computation stable and tractable

Rescaling the weights before exponentiating. Computing wi=e−riw_i = e^{-r_i} directly underflows when every neighbour is far away, giving 0/00/0 for numerical rather than statistical reasons. Because the estimator is a ratio, subtracting a constant from every exponent leaves it unchanged:

∑ie−riyi∑ie−ri=∑ie−(ri−rmin⁡)yi∑ie−(ri−rmin⁡)\frac{\sum_i e^{-r_i} y_i}{\sum_i e^{-r_i}} = \frac{\sum_i e^{-(r_i - r_{\min})} y_i}{\sum_i e^{-(r_i - r_{\min})}}

With rmin⁡r_{\min} subtracted, the largest weight is exactly 1 (the log-sum-exp trick). The rescaled weights are no longer in the same units as η\eta, so the prior term must be scaled by the same factor; otherwise the amount of shrinkage depends on how far away the neighbours are.

Keeping a radius cutoff. A kernel gives every point a weight, so truncation is no longer needed for the estimator to be defined. It is kept for cost: without it every query touches every observation, which is infeasible with millions of trajectory points, so only observations with r≤Rr \le R are used. With RR large the cutoff is a computational approximation; at R=5R = 5 the largest discarded weight is e−5≈7×10−3e^{-5} \approx 7 \times 10^{-3}, under 1% of the weight of an observation at the query point. With RR smaller, the cutoff changes the estimate and becomes part of the model.

Length scales are fitted on held-out groups

The parameters lsl_s, ltl_t, lfl_f, η\eta and μ0\mu_0 are chosen by minimising a loss on held-out data; for a probability, binary cross-entropy:

L(θ)=−1∣Q∣∑q∈Q[yqlog⁡p^q+(1−yq)log⁡(1−p^q)]\mathcal{L}(\boldsymbol{\theta}) = -\frac{1}{|Q|}\sum_{q \in Q} \left[ y_q \log \hat{p}_q + (1-y_q)\log(1-\hat{p}_q)\right]

Holding out random observations does not work here. Consecutive points along one flight are close together, so a held-out point almost always has a near-duplicate in the training set, and the score measures recall of that duplicate rather than generalisation. Grouped cross-validation holds out entire flights instead, so every validation query is separated from the data the model sees. In general, when observations arrive in correlated groups, cross-validation should split by group.

Assumptions and failure modes

The estimator treats its observations as independent. Ten observations from one flight within a kilometre of each other receive ten times the weight of one, although they are nearly the same measurement; ∑iwi\sum_i w_i counts evidence without accounting for its correlation.

It also returns no uncertainty. p^\hat{p} is a single number whether it rests on hundreds of nearby observations or on the prior alone. Both limitations have the same origin and are addressed by Gaussian Process Regression.

Summary

  • Nadaraya–Watson regression is a weighted mean with weights that decrease with normalised distance.
  • The exponential kernel keeps distant observations at a reduced weight; the Gaussian effectively discards them.
  • A Beta prior with strength η\eta, in units of observations, makes the estimate relax smoothly to μ0\mu_0 where data are sparse.
  • Parameters are fitted by cross-entropy on held-out groups (for example, whole flights), not random points.

The output is a number in [0,1][0,1]; whether it behaves as a probability is the subject of the next tutorial.

References

  • Nadaraya, E. A. (1964). On estimating regression. Theory of Probability & Its Applications, 9(1), 141–142. doi:10.1137/1109020
  • Watson, G. S. (1964). Smooth regression analysis. Sankhyā: The Indian Journal of Statistics, Series A, 26(4), 359–372. JSTOR 25049340
  • Roberts, D. R., Bahn, V., Ciuti, S., Boyce, M. S., Elith, J., Guillera-Arroita, G., Hauenstein, S., Lahoz-Monfort, J. J., Schröder, B., Thuiller, W., Warton, D. I., Wintle, B. A., Hartig, F., & Dormann, C. F. (2017). Cross-validation strategies for data with temporal, spatial, hierarchical, or phylogenetic structure. Ecography, 40(8), 913–929. doi:10.1111/ecog.02881