Kriging::leaveOneOutFun

Description

Compute the Leave-One-Out (LOO) Sum of Squares of Errors for a Kriging Object and a Vector \(\boldsymbol{\theta}\) of Correlation Ranges

Usage

  • Python

    # k = Kriging(...)
    k.leaveOneOutFun(theta, grad = FALSE)
    
  • R

    # k = Kriging(...)
    k$leaveOneOutFun(theta, grad = FALSE)
    
  • Matlab/Octave

    % k = Kriging(...)
    k.leaveOneOutFun(theta, grad = FALSE)
    

Arguments

Argument

Description

theta

A numeric vector of range parameters at which the LOO sum of squares will be evaluated.

grad

Logical. Should the gradient (w.r.t. theta ) be returned?

Details

The Leave-One-Out (LOO) sum of squares is defined by \(\texttt{SS}_{\texttt{LOO}}(\boldsymbol{\theta}) := \sum_{i=1}^n \{y_i - \widehat{y}_{i\vert -i}\}^2\) where \(\widehat{y}_{i\vert -i}\) denotes the prediction of \(y_i\) based on the observations \(y_j\) with \(j \neq i\). The vector \(\widehat{\mathbf{y}}_{\texttt{LOO}}\) of LOO predictions is computed efficiently, see here for details.

Value

The value \(\texttt{SSE}_{\texttt{LOO}}(\boldsymbol{\theta})\) of the Leave-One-Out Sum of Squares for the given vector \(\boldsymbol{\theta}\) of correlation ranges.

Examples

f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7)
set.seed(123)
X <- as.matrix(runif(10))
y <- f(X)

k <- Kriging(y, X, kernel = "matern3_2", objective = "LOO", optim="BFGS")
print(k)

loo <-  function(theta) k$leaveOneOutFun(theta)$leaveOneOut
t <-  seq(from = 0.001, to = 2, length.out = 101)
plot(t, loo(t), type = "l")
abline(v = k$theta(), col = "blue")

Results

* data: 10x[0.0455565,0.940467] -> 10x[0.194057,1.00912]
* trend constant (est.): 0.406331
* variance (est.): 0.0471509
* covariance:
  * kernel: matern3_2
  * range (est.): 0.284722
  * fit:
    * objective: LOO
    * optim: BFGS