Linear Prediction for Spatial and Spatio-Temporal Fields
36-740, Fall 2026
10 September 2026 (Lecture 6)
\[
\newcommand{\Expect}[1]{\mathbb{E}\left[ #1 \right]}
\newcommand{\Var}[1]{\mathrm{Var}\left[ #1 \right]}
\newcommand{\SampleVar}[1]{\widehat{\mathrm{Var}}\left[ #1 \right]}
\newcommand{\Cov}[1]{\mathrm{Cov}\left[ #1 \right]}
\newcommand{\TrueRegFunc}{\mu}
\newcommand{\EstRegFunc}{\widehat{\TrueRegFunc}}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator*{\argmin}{argmin}
\DeclareMathOperator{\det}{det}
\newcommand{\TrueNoise}{\epsilon}
\newcommand{\EstNoise}{\widehat{\TrueNoise}}
\newcommand{\AutoCov}{\gamma}
\newcommand{\LinearExpect}[1]{\mathbb{L}\left[ #1 \right]}
\]
In our previous episode
- General approach to optimal linear prediction
- Predict \(Y\) from \(\vec{Z} = [Z_1, Z_2, \ldots Z_p]\)
- Best linear prediction is \(\LinearExpect{Y|Z} = \alpha + \vec{\beta} \cdot \vec{Z}\)
- Best \(\alpha = \Expect{Y} - \vec{\beta} \cdot \Expect{\vec{Z}}\)
- Best \(\beta = \Var{\vec{Z}}^{-1} \Cov{\vec{Z}, Y}\)
- Today: application to spatial and spatio-temporal data
- What can this do for us?
- How do we find the covariances?
Optimal linear prediction for spatial data
- Given: \(X(r_1), X(r_2), \ldots X(r_n)\)
- Desired: prediction of \(X(r_0)\)
\[\begin{eqnarray}
\EstRegFunc(r_0) & = & \alpha + \vec{\beta} \cdot \left[\begin{array}{c} X(r_1) \\ X(r_2) \\ \vdots \\ X(r_n) \end{array}\right]\\
\alpha & = & \Expect{X(r_0)} - \vec{\beta} \cdot \left[\begin{array}{c} \Expect{X(r_1)}\\ \Expect{X(r_2)} \\ \vdots \\ \Expect{X(r_n)}\end{array}\right] ~ \text{(goes away if everything's centered)}\\
\vec{\beta} & = & {\left[\begin{array}{cccc} \Var{X(r_1)} & \Cov{X(r_1), X(r_2)} & \ldots & \Cov{X(r_1), X(r_n)}\\
\Cov{X(r_1), X(r_2)} & \Var{X(r_2)} & \ldots & \Cov{X(r_2), X(r_n)}\\
\vdots & \vdots & \ldots & \vdots\\
\Cov{X(r_1), X(r_n)} & \Cov{X(r_2), X(r_n)} & \ldots & \Var{X(r_n)}\end{array}\right]}^{-1} \left[\begin{array}{c} \Cov{X(r_0), X(r_1)}\\
\Cov{X(r_0), X(r_2)}\\ \vdots \\ \Cov{X(r_0), X(r_n)}\end{array}\right]
\end{eqnarray}\]
This should look familiar
- It’s exactly the same as optimal linear prediction for time series
- “Using linear prediction on spatial data” is called kriging
- We’ll come back to the name later
What do we need to know?
- \(\Expect{X(r)}\)
- \(\Var{X(r)}\)
- \(\Cov{X(r), X(q)}\)
- Problem: we only have one observation of each \(X(r)\)
Expectation values
- We can estimate \(\Expect{X(r)}\) by smoothing
- Assuming \(\TrueRegFunc(r)\) doesn’t change very rapidly
- Need to pick a smoother
- Assuming \(\Expect{X(r)} =\) constant is one choice of smoother…
- Moving averages can work, splines are nice…
- Or we can assume spatial stationarity and use the global mean
- See back-up about (potentially) improving on this
What about variance and covariance?
\[
\Cov{X(r), X(q)} = \Expect{X(r)X(q)} -\TrueRegFunc(r) \TrueRegFunc(q) = \Expect{(X(r)-\TrueRegFunc(r))(X(q) - \TrueRegFunc(q))}
\]
If we saw \(m\) realizations of \(X(r)\) and \(X(q)\), we could use \[
\Cov{X(r), X(q)} \approx \frac{1}{m}\sum_{i=1}^{m}{(X^{(i)}(r)-\TrueRegFunc(r))(X^{(i)}(q) - \TrueRegFunc(q))}
\]
but we see \(X(r)\) and \(X(q)\) only once
- To get anywhere, we need to assume something about how the covariance function works
- Useful assumptions are restrictions on \(\Cov{X(r), X(q)}\)
- We could assume some covariances are exactly equal, so we can pool the corresponding pairs of points in estimating the covariance
- Or we could assume \(\Cov{X(r), X(q)}\) is a smooth function of \(r\) and \(q\), and use smoothing
- Or both
Smoothing for covariance estimation
- Two (equivalent) definitions of the covariance: \[
\Cov{X(r), X(s)} = \Expect{X(r) X(s)} - \Expect{X(r)}\Expect{X(s)} = \Expect{(X(r) - \Expect{X(t)}) (X(s) - \Expect{X(s)})}
\]
- Use the 2nd form: define \[
\Gamma(r,s) \equiv (X(r) - \Expect{X(r)})(X(s) - \Expect{X(s)})
\] so \(\Cov{X(r), X(s)} = \Expect{\Gamma(r,s)}\)
- Now assume constant mean so we can estimate \[
\widehat{\Gamma}(r,s) = (X(r) - \overline{x}) (X(s) - \overline{x})
\]
- Or substitute in trend estimates of your choice
- Now assume stationarity so \(\Cov{X(r), X(s)} = \Expect{\Gamma(r,s)} = \AutoCov(r-s)\)
- Finally assume \(\AutoCov(h)\) changes slowly in \(h\)
- We can estimate \(\AutoCov(h)\) by finding pairs \(r, s\) with \(r-s \approx h\) and averaging \(\widehat{\Gamma}(r,s)\)
- Or kernel smoothing or spline smoothing or…
- Warning: not necessarily a valid covariance function
Some restrictions on \(\Cov{X(r), X(q)}\)
- Stationarity: for any displacement vector \(h\), \[
\Cov{X(r), X(r+h)} = \Cov{X(q), X(q+h)} \equiv \gamma(h)
\]
- Often also assume \(\TrueRegFunc(q) =\) constant
- Lets us pool pairs of points separated by the same displacement
- Can be checked:
- Sub-divide data in space
- Re-estimate the covariance function in each spatial region
- Do they match?
Some restrictions on \(\Cov{X(r), X(q)}\)
- Isotropy (in 2 or 3D): if \(\|h\| = \|k\|\), then \[
\Cov{X(r), X(r+h)} = \Cov{X(r), X(r+k)}
\]
- Lets us pool pairs of points separated by the same distance from \(r\)
- Can also be stationary and isotropic
- That lets us pool pairs of points at the same distance
- Can be checked:
- Sub-divide data into pairs of points separated in the same (or similar) directions
- Re-estimate the covariance function along each direction
- Do they match?
Some restrictions on \(\Cov{X(r), X(q)}\)
- Separability: In 2D, \(r=(r_1, r_2)\) and \(q=(q_1, q_2)\), \[
\Cov{X(r), X(q)} = C_1(r_1, q_1) C_2(r_2, q_2)
\]
- Similarly for 3D
- Lets us pool pairs of points with same \(r_1, q_1\) (for \(C_1\))
- Can also be stationary and separable
- Lets us pool pairs of points with same \(r_1 - q_1\) (for \(C_1\))
- Often unphysical but assumed for statistical convenience
- Is separable and isotropic possible?
- Can be checked:
Estimating a stationary covariance function
- For each \(h\), \(n_h =\) number of \(r_i, r_j\) pairs with \(r_i - r_j = h\) \[
\hat{\gamma}(h) = \frac{1}{n_h} \sum_{i, j ~ : ~ r_i - r_j = h}{(X(r_i) - \EstRegFunc(r_i)) (X(r_j) - \EstRegFunc(r_j))}
\]
- Works best on a regular grid…
- … which we don’t always have
Think of the Irish wind data

What about Belfast?

(Why is Belfast not in the data set?)
Try a stationary, isotropic covariance
- Assume \(\TrueRegFunc =\) constant so \(\EstRegFunc= 5.26\).
- Assume \(\Cov{X(r), X(q)} = \gamma(\|r-q\|)\)
- Plot \((X(r_i) - \EstRegFunc(r_i)) (X(r_j) - \EstRegFunc(r_j))\) against \(r_i - r_j\)
global.mean <- mean(wind.loc$MeanWind)
distances <- spDists(coordinates(wind.loc), longlat = TRUE)
c.rq <- outer(wind.loc$MeanWind - global.mean, wind.loc$MeanWind - global.mean, "*")
rho.rq <- c.rq/var(wind.loc$MeanWind)
Try a stationary, isotropic covariance
plot(x = as.vector(distances), y = as.vector(rho.rq), xlab = "Distance (km)", ylab = expression((x(r) -
bar(x))(x(q) - bar(x))/sigma^2))
lines(smooth.spline(x = as.vector(distances), y = as.vector(rho.rq), cv = TRUE))
L.rough <- -log(0.14)/100
curve(exp(-L.rough * x), add = TRUE, col = "blue")
legend("topright", legend = c("Data", "Spline", "Exponential"), pch = c(1, NA, NA),
lty = c("blank", "solid", "solid"), col = c("black", "black", "blue"))

Try a stationary, isotropic covariance
- Fit the spline first to guide the eye
- Tried exponential decay because that often works
- \(\rho(\|h\|) = e^{-\|h\| \lambda}\), \(1/\lambda=\) correlation length
- Rough guess at \(\lambda\) from how much the spline had fallen in 100km
- In this case, \(1/\lambda \approx 51 \mathrm{km}\)
- Could improve this through fitting the exponential model (see back-up slides on nonlinear least squares)
- Sometimes try \(\rho(\|h\|) = c\mathbf{1}(h=0) + (1-c)e^{-\|h\| \lambda}\), nugget effect
- This looks weird and has a silly name but there’s a reason for it which we’ll come to next week
Kriging
wind.prediction <- function(r, L) {
fit <- c(fit = NA, se = NA)
global.mean <- mean(wind.loc$MeanWind)
global.var <- var(wind.loc$MeanWind)
distances.to.r <- spDistsN1(pts = coordinates(wind.loc), pt = r, longlat = TRUE)
distances.among.q <- spDists(coordinates(wind.loc), longlat = TRUE)
corYZ <- exp(-L * distances.to.r)
corZ <- exp(-L * distances.among.q)
Z <- wind.loc$MeanWind
fit["fit"] <- global.mean + (Z - global.mean) %*% solve(corZ) %*% corYZ
fit["se"] <- sqrt(global.var - t(corYZ) %*% solve(corZ) %*% corYZ)
return(fit)
}
wind.prediction(r = as.numeric(belfast.longlat), L = L.rough)
## fit se
## 5.362427 1.358965
Spatio-temporal prediction
- Once more, with feeling
- The math is exactly the same
- Again: all about estimating covariance functions
- Stationarity: over space? over time? both?
- If stationary over both space and time, \(\Cov{X(r,t), X(q,s)} = \Cov{X(0,0), X(r-q, s-t)} = \gamma(r-q, s-t)\)
- Taylor hypothesis (Gneiting, Genton, and Guttorp 2007): for some velocity \(v\), \(\gamma(0,t) = \gamma(vt,0)\)
- (after G. I. Taylor, see Batchelor (1996); often useful in fluid flows)
- Isotropy: usually only makes sense for space, not for space+time
- \(\|h\| = \|k\|\) \(\Rightarrow\) \(\Cov{X(r,t), X(r+h, s)} = \Cov{X(q,t), X(q+k, s)}\)
- Separability: space from time? coordinates of space?
- Space-time separability is often even more artificial than spatial separability
Prediction error
- General result for optimal linear prediction:
\[
Expect{(Y - \LinearExpect{Y|Z})^2} = \Var{Y-\LinearExpect{Y|Z}} = \Var{Y} - \Cov{Y,Z}^T (\Var{Z})^{-1} \Cov{Y,Z}
\]
- This is fine if the Oracle tells us the covariance function
- We need to estimate the covariance \(\Rightarrow\) more uncertainty
- Some approximations, e.g., Zimmerman and Cressie (1992)
Some historical notes: Krige
- The technology of optimal linear prediction we saw for time series was independently re-invented, for purely spatial data, in geology by D. G. Krige in 1951
- Krige was a mining engineer in South Africa who wanted to estimate the mineral value of new sites from old sites
- Reference: Krige (1981)
- Krige does not appear to have known about Wiener, Kolmogorov, etc.
Some historical notes: “kriging”, “geostatistics”
- Krige’s work was taken up by French mathematicians and engineers in the 1960s and 1970s
- The link was Georges Matheron, a mathematician and mining engineer who was the chief scientist for the mining operations in Algeria when it was a French colony (Matheron 2019)
- “Kriging” = French mathematicians and engineers inventing an English verb for “using optimal linear prediction on spatial data”
- “Geostatistics” = French mathematicians and engineers getting really into covariance functions on \(\mathbb{R}^2\) and/or \(\mathbb{S}^2\)
- A peculiar jargon, and some distinctive ideas, developed in parallel to the rest of statistics
- Ripley (1981), ch. 4, was an early, influential, and still very useful translation into mainstream statistical terms
Summary
- Spatial and spatio-temporal prediction works just like time series
- The only trick is estimating covariances
Backup: Estimating the Mean of a Stationary Random Field
Backup: Valid covariance functions
- \(\Cov{X(r), X(q)}\) can’t be just any function of \(r\) and \(q\)
- \(\Cov{X(r), X(r)} \geq 0\), all implied correlations \(\in [-1, 1]\), etc.
- For every valid \(\Cov{X(r), X(q)}\), for any set of points \(r_1, r_2, \ldots r_n\), the matrix \(c_{ij} = \Cov{X(r_i), X(r_j)}\) is non-negative definite
- i.e., \(\mathbf{v}^T \mathbf{c} \mathbf{v} \geq 0\) for any vector \(\mathbf{v}\)
- Any function of \(r\) and \(q\) which always leads to non-negative definite matrices is the covariance function of some distribution
- The point of the French mathematicians’ work on geostatistics in the 1960s and 1970s was to realize this, and to use it to restrict the search for covariance functions to ones which are non-negative definite
- Gneiting, Genton, and Guttorp (2007) has a good discussion, but needs Fourier analysis
Backup: Varieties of kriging
The geostatistics people distinguished a lot of varieties of kriging:
- Simple kriging: assumes weak stationarity, with known mean and covariance function
- Ordinary kriging: assumes weak stationarity, estimate the mean by generalized least squares, still taking the covariance function as known
- Universal kriging; assumes a translation-invariant covariance function but the mean varies spatially, and is a linear function of some measured spatial variable; estimate the linear model by generalized least squares
- etc., etc.
Backup: Parametric covariance (or correlation) estimation
- \(\Cov{X(r), X(q)} = \Expect{(X(r)-\TrueRegFunc(r))(X(q)-\TrueRegFunc(q))}\)
- For each pair of points \(r\) and \(q\), create the product of deviations \(C(r,q) = (X(r) - \EstRegFunc(r))(X(q) - \EstRegFunc(q))\)
- If we had many realizations of \(X(r), X(q)\), we could average \(C(r,q)\) to estimate \(\Cov{X(r), X(q)}\)
- Assume instead that we have a parametric form for the covariance, \(\Cov{X(r), X(q)} = f(r,q,\theta)\) (parameter \(\theta\) unknown)
- E.g., \(f(r,q,\lambda, \sigma^2) = \sigma^2 e^{-\|r-q\|\lambda}\) for a stationary, isotropic, exponentially-decaying covariance, with correlation length \(1/\lambda\) and variance \(\sigma^2\)
- Then \(C(r,q) = f(r,q,\theta)+\) noise, with noise having mean 0
- Use nonlinear least squares (NLS): \[
\hat{\theta} = \argmin_{\theta}{\frac{1}{n^2}\sum_{i=1}^{n}{\sum_{j=1}^{n}{{\left( C(r_i, r_j) - f(r_i, r_j, \theta)\right)}^2}}}
\]
- Can apply this to correlations rather than covariances if the variances are known, or assumed constant
Backup: Nonlinear least squares
- General setting: \(Y=f(Z,\theta) +\) noise
- data \((z_1, y_1), (z_2, y_2), \ldots (z_m, y_m)\)
- NLS estimate is \[
\hat{\theta} = \argmin_{\theta}{\frac{1}{m}{\sum_{i=1}^{m}{{\left( y_i - f(z_i, \theta)\right)}^2}}}
\]
- Statistical properties very similar to ordinary least squares, but computationally more annoying
- Statistically, optimization methods are all pretty similar, and we’ll see the theory in a few weeks
- Computationally, no closed-form solution (unlike OLS), so you need to iteratively approach the optimum
- In R: either
nls (specifically for nonlinear least squares) or optim (for general-purpose optimization)
- Usually needs an initial guess about \(\theta\)
Backup: Nonlinear least squares illustrated
Using optim():
rho.mse <- function(L) {
mean((rho.rq - exp(-L * distances))^2)
}
L.optim <- optim(par = L.rough, fn = rho.mse, method = "BFGS")
L.optim$par
## [1] 0.02432098
so estimated correlation length is \(41 \mathrm{km}\) rather than initial guess of \(51 \mathrm{km}\)
Backup: Nonlinear least squares illustrated
Using nls():
nls(as.vector(rho.rq) ~ exp(-L * as.vector(distances)), start = list(L = L.rough))
## Nonlinear regression model
## model: as.vector(rho.rq) ~ exp(-L * as.vector(distances))
## data: parent.frame()
## L
## 0.02428
## residual sum-of-squares: 109.6
##
## Number of iterations to convergence: 5
## Achieved convergence tolerance: 3.649e-06
Backup: “Variograms”
- A lot of the geostatistical literature emphasizes idea of the variogram \[
v(r, s) = \frac{1}{2}\Var{X(r) - X(s)}
\]
- Notice that \[
v(r,s) = \frac{1}{2}\left(\Var{X(r)} + \Var{X(s)} - 2\Cov{X(r), X(s)}\right)
\] so if you know the variances, the variogram and the covariance function are equivalent
- If variance is constant, \(\Var{X(r)} = \sigma^2\), \[
v(r,s) = \sigma^2 - \Cov{X(r), X(s)}
\]
- Any assumption that constrains the covariance function constrains the variogram and vice-versa, e.g., stationarity, \[
v(r,s) = v(r-s)
\] so we can pool data to estimate
(There are some situations where \(v(r,s)\) is well-defined but \(\Cov{X(r), X(s)}\) is not, but they are weird)
Backup: Generalized Least Squares and Gauss-Markov
- Given: \(\mathbf{y}\) (\(n\times 1\)), \(\mathbf{x}\) (\(n \times p\)), positive-definite \(\mathbf{v}\) (\(n\times n\))
- We decided to minimize \[
\frac{1}{n}(\mathbf{y} -\mathbf{x} b)^T \mathbf{v}^{-1} (\mathbf{y} - \mathbf{x} b)
\]
- The solution is \[
\hat{\beta}_{GLS} = (\mathbf{x}^T \mathbf{v}^{-1} \mathbf{x})^{-1} \mathbf{x}^T \mathbf{v}^{-1} \mathbf{y}
\]
- Assume \(\Expect{Y|X} = \beta \mathbf{X} + \epsilon\), and \(\Expect{\epsilon} = 0\)
- Then \(\Expect{\hat{\beta}_{GLS}} = \beta\) (unbiased)
- If \(\Var{\epsilon} = \mathbf{v}\), then \(\hat{\beta}_{GLS}\) is the minimum variance unbiased linear estimator of \(\beta\) (Gauss-Markov theorem)
- Despite the name, does not require the noise to be Gaussian
- Proof: Not given here, but see Shalizi (n.d.), sec. 10.2.2
References
Batchelor, G. K. 1996. The Life and Legacy of G. I. Taylor. Cambridge, England: Cambridge University Press.
Gneiting, Tilmann, Marc G. Genton, and Peter Guttorp. 2007. “Geostatistical Space-Time Models, Stationarity, Separability, and Full Symmetry.” In Statistical Methods for Spatio-Temporal Systems, edited by Bärbel Finkenstädt, Leonhard Held, and Valerie Isham, 151–75. Boca Raton, Florida: Chapman; Hall/CRC. https://doi.org/10.1201/9781420011050.
Zimmerman, Dale L., and Noel Cressie. 1992. “Mean Squared Prediction Error in the Spatial Linear Model with Estimated Covariance Parameters.” Annals of the Institute of Statistical Mathematics 44:27–43. https://doi.org/10.1007/BF00048668.