Switches from one covariance to another along one input column, smoothly around an estimable location: a structural break in a time series, or a regime change in space.
Arguments
- before, after
Kernel specifications that hold before and after the change.
- location
Finite location \(c\) of the change, in the units of the input column.
- steepness
Positive steepness \(a\) of the transition, in inverse input units: the transition takes about \(4 / a\) from 12% to 88%.
- column
The input column along which the change happens.
Details
With the sigmoid \(s(x) = 1 / (1 + e^{-a (x_t - c)})\) along column
\(t\),
$$k(x, x') = (1 - s(x)) k_1(x, x') (1 - s(x')) +
s(x) k_2(x, x') s(x'),$$
where \(k_1\) is before and \(k_2\) is after. Each term has the
form \(g(x) k(x, x') g(x')\), so the kernel is positive semidefinite.
The two regimes are independent processes: as \(a \to \infty\), the
covariance between points on opposite sides of \(c\) tends to 0.
location is a real-valued parameter, optimized on the identity scale,
and steepness a positive one, optimized on the log scale. Parameter
paths are location and steepness for the change itself, and
before. and after. for the two kernels, so nested changepoints model
several changes. optimize_gp() bounds every changepoint location by the
training range of its column and, because the likelihood is often
multimodal in the location, starts it at evenly spaced quantiles of that
column.
The kernel is as smooth as its two components, so it supports
kernel_input_gradient(), predict_gradient_gp(), and derivative
observations when they do.
Stability
Experimental: this interface may change in a minor release, and every change is listed in NEWS. See gaussianprocesses-package for the policy.
See also
time_series_kernel(), whose changepoint argument adds a
change to the time-series kernel.
Examples
kernel <- changepoint_kernel(
before = rbf_kernel(variance = 1, length_scale = 2),
after = rbf_kernel(variance = 0.2, length_scale = 0.5),
location = 5,
steepness = 4
)
kernel
#> ChangepointKernel(location=5, steepness=4, column=1,
#> RBF(variance=1, length_scale=2)
#> RBF(variance=0.2, length_scale=0.5)
#> )
names(kernel_parameters(kernel, flatten = TRUE))
#> [1] "location" "steepness" "before.variance"
#> [4] "before.length_scale" "after.variance" "after.length_scale"
# Points on opposite sides of a steep change are nearly uncorrelated.
evaluate_kernel(kernel, c(4, 6))
#> [,1] [,2]
#> [1,] 0.96441578 0.01071416
#> [2,] 0.01071416 0.19319372