Computes the exact Gaussian log marginal likelihood from a fitted model using its stored Cholesky factor and solve vector.
Details
If numerical jitter was required during fitting, the stored Cholesky factor corresponds to the jitter-stabilized covariance used by the numerical calculation. Jitter remains distinct from statistical observation noise.
For a mean with estimated coefficients, the value is the profile
likelihood, at the generalized least-squares estimate \(\hat\beta\)
(estimate_coefficients("ml")), or the restricted likelihood
(estimate_coefficients("reml")). For coefficients with a Gaussian prior
it is the marginal likelihood of the Gaussian process with covariance
\(k(x, x') + h(x)^\top B h(x')\), and for a vague prior it is the
restricted likelihood. mean_coefficients gives the formulas.
For a latent model from fit_latent_gp() or optimize_latent_gp() the
value is the Laplace approximation \(\log q(y \mid X, \theta)\). For
a state-space model from fit_time_series_gp() it is the exact log
marginal likelihood from the Kalman filter's prediction errors.
Stability
Stable: from version 1.0.0 this interface changes incompatibly only in a major release, after a deprecation period. Results and options that concern an experimental model class, kernel, or argument follow that interface's tier. See gaussianprocesses-package for the policy.
Examples
x <- seq(-2, 2, length.out = 15)
y <- sin(2 * x)
# Compare candidate length scales by their marginal likelihood.
sapply(c(0.2, 0.6, 2), function(length_scale) {
log_marginal_likelihood(
fit_gp(x, y, rbf_kernel(length_scale = length_scale), noise_variance = 0.01)
)
})
#> [1] -15.0384077 -0.2349538 -55.2897086