Scope note: This note fits a statistical model to a published series to show how a kernel represents structure. The forecast extrapolates that model. It is not a projection from the physics, ecology or economics of the series, and the series is used as published, without the corrections a domain analysis would apply.
The yearly flow of the Nile at Aswan from 1871 to 1970, the Durbin and Koopman series from Rdatasets, remains high in the early decades before settling lower. A purely smooth kernel plus noise absorbs that jump as one broad wiggle. Writing a custom kernel makes it possible to represent a distinct pre-shift level around an unknown changepoint $c$. Define the smooth switch
$$ h(t) = \frac{1}{2}\left(1 - \tanh\frac{t - c}{w}\right) , $$which stays close to $1$ well before $c$ and decays to $0$ after $c$ over width $w$. Combining a switched offset with a smooth residual term and independent noise yields
$$ \begin{aligned} k(s,t) ={}& a^2\,h(s)\,h(t) \\ &+ d^2 \exp\!\left(-\frac{(s-t)^2}{2\ell^2}\right) \\ &+ \sigma_\varepsilon^2\,\delta(s,t) , \end{aligned} $$written in symbolic form as
(1 - tanh((s - c) / w)) * (1 - tanh((t - c) / w)) / 4 * Const(a) + RBF(l, d) + WN(n)
with a constant mean $\mu$. The leading term is the covariance of $h(t)\,a\,z$ for a single standard normal variable $z$, giving a random offset of standard deviation $a$ active before $c$ and absent afterwards. Multiplying any kernel $k(s,t)$ by $h(s)\,h(t)$ always preserves positive semi-definiteness because it is the covariance of $h(t)f(t)$, here applied to $f(t) = a z$. The µGauss reference lists this multiplicative construction among valid kernel forms.
Searching $c$ over $[1880, 1920]$ with fixed transition width $w = 2$ years gives a log likelihood of $-628.4$ and a BIC of $1284$.
| Name | Symbol | Value | Standard error |
|---|---|---|---|
c | $c$ | $1898$ | $1.1$ years |
a | $a$ | $249$ | $179$ |
l | $\ell$ | $0.96$ years | $0.94$ |
d | $d$ | $70$ | $39$ |
n | $\sigma_\varepsilon$ | $108$ | $26$ |
Run this in µGauss
Open µGauss with this model pre-loaded to inspect the fit, forecast, and parameter sensitivities, or adjust the kernel and refit:
- Open the model with the switch in µGauss ↗. The statistics card tracks the posterior mean of $x$ in 1880, 1895, 1910, and 1950.
- Open the same series without the switch in µGauss ↗, fitted with
RBF(l, a) + WN(n).

Identifying the level shift
The posterior mean drops from $1168$ in 1895 to $904.6$ in 1910 and remains near $850$ to $900$ afterwards, reaching $846.9$ in 1950, a step of roughly $260$ units. Although the fitted scale $a = 249$ matches that jump, its standard error is $179$ because a single realization cannot tightly constrain the standard deviation of the distribution one random offset came from. By contrast, the data pin down both the realized step itself and the changepoint timing $c = 1898$ to within about a year.
Evidence for the changepoint
Fitting the smooth model RBF(l, a) + WN(n) without a switch reaches a log likelihood of $-638.3$ and a BIC of $1295$.
| Model | Free parameters | Log likelihood | BIC |
|---|---|---|---|
| Smooth term and noise | $3$ | $-638.3$ | $1295$ |
| Switch, smooth term, and noise | $5$ | $-628.4$ | $1284$ |
Adding the switch costs two free parameters and gains $9.9$ in log likelihood, lowering the BIC by $11$. That drop gives strong evidence for an early regime shift that the stationary smooth term cannot capture cleanly. Across 4 restarts, 3 reached the global optimum while one stopped at a local maximum with log likelihood $-639.7$.
Related notes: Squared exponential kernel on the Nile flow, Exponential kernel as an AR(1) process. Kernel-preserving rules appear in the µGauss reference, and writing a custom formula step by step is covered in Using µGauss.