Universal kriging (source code)

= Universal kriging

<Universal kriging> allows an unknown <regression> drift:
$$
\mathbb E[Z]=X\beta,\qquad \mathbb E[Z_0]=x_0^T\beta.
$$
The <design matrix> $X$ has full column rank, its entries and $x_0$ are known, and the <regression coefficients> $\beta$ are unknown. For example, rows $(1,s_i)$ and target row $(1,s_0)$ allow a linear spatial trend. Requiring $w^TZ$ to have zero <bias> for every $\beta$ gives $X^Tw=x_0$. With known <positive-definite matrix> observation <covariance matrix> $\Sigma$, the minimizing weights solve
$$
\begin{pmatrix}\Sigma&X\\X^T&0\end{pmatrix}
\begin{pmatrix}w\\\eta\end{pmatrix}
=\begin{pmatrix}c\\x_0\end{pmatrix},
$$
where $\eta$ is a vector of <Lagrange multipliers>. Equivalently, the <generalized least squares> estimate and prediction are
$$
\widehat\beta=(X^T\Sigma^{-1}X)^{-1}X^T\Sigma^{-1}z,
\qquad
\widehat Z_0=x_0^T\widehat\beta+c^T\Sigma^{-1}(z-X\widehat\beta).
$$
The first term is the estimated trend alone; the second predicts the correlated <regression residuals>. With $q=x_0-X^T\Sigma^{-1}c$, the error <variance> is
$$
s_{\mathrm{UK}}^2=v_0-c^T\Sigma^{-1}c
+q^T(X^T\Sigma^{-1}X)^{-1}q.
$$
The last, nonnegative term accounts for estimating the specified drift coefficients. Merely inserting a fitted drift into <simple kriging> and keeping its known-<mean> error <variance> would omit this term. For a <Gaussian random field>, the same expressions arise by integrating over drift coefficients in a diffuse <prior distribution> limit; this is an additional inferential interpretation, not an assumption required by the linear optimization.<Gaussian Processes for Machine Learning by Carl Edward Rasmussen and Christopher K. I. Williams>[§2.7, pp. 27–28, equations (2.38)–(2.42)]{ref}