Optimize the hyperparameters of a time-series GP
Source:R/gp-time-series.R
optimize_time_series_gp.RdEstimates the kernel parameters and the noise of a GP on ordered
time-series observations by maximizing the log marginal likelihood, with
the optimizer of optimize_gp().
Usage
optimize_time_series_gp(
time,
y,
kernel,
unit = "auto",
method = c("exact", "state_space"),
...
)Arguments
- time
Numeric, Date, or POSIXt vector in strictly increasing order.
- y
Numeric response vector.
- kernel
Initial kernel specification.
- unit
Time unit passed to
gp_time_index().- method
"exact"conditions a Gaussian prior on the observations withfit_gp()."state_space"computes the same posterior and log marginal likelihood in \(O(n)\) time by Kalman filtering and smoothing; it needs a Matérn-1/2, 3/2, or 5/2 kernel, a sum of such kernels, or scaled versions of them (see State-space inference).- ...
Additional arguments passed to
optimize_gp(). Withmethod = "state_space", the argumentsnoise_variance,mean,optimize_noise,n_starts,start_spread,lower,upper, andcontrolapply, with the meanings and defaults ofoptimize_gp().
Value
A fitted model as returned by fit_time_series_gp(), with
optimizer diagnostics in $optimization.
Details
With method = "state_space" each objective value is one Kalman filter
pass, in \(O(n)\) time (fit_time_series_gp() describes the method).
Gradients are finite-difference approximations by L-BFGS-B
(gradient = "numerical" in optimize_gp()); analytical sensitivity
recursions are not implemented yet.
Stability
Experimental: this interface may change in a minor release, and every change is listed in NEWS. See gaussianprocesses-package for the policy.
Examples
set.seed(1)
time <- sort(runif(200, 0, 50))
y <- sin(time / 3) + rnorm(200, sd = 0.2)
model <- optimize_time_series_gp(time, y, matern52_kernel(),
noise_variance = 0.1, n_starts = 1, method = "state_space")
model$optimization$optimized_parameters
#> variance length_scale noise_variance
#> 1.55681386 8.20864673 0.03920353