loo: Leave-One-Out Cross-Validation

View source: R/loo.R

looR Documentation

Leave-One-Out Cross-Validation

Description

Calculation of the leave-one-out prediction, standard deviation and confidence intervals of a gekm object.

Usage

## S3 method for class 'gekm'
loo(object, reestim = TRUE, sd.fit = TRUE, scale = FALSE, 
	df = NULL, interval = c("none", "confidence"), level = 0.95, ...)

Arguments

object

an object of class "gekm".

reestim

logical. Should the regression coefficients be re-estimated? Default is TRUE.

sd.fit

logical. Should the standard deviation of the prediction, i.e., the root mean squared error, be computed? Default is TRUE.

scale

logical. Should the estimated process variance be scaled? Default is FALSE, see sigma.gekm for details.

df

degrees of freedom for the t distribution. Default is NULL, see ‘Details’.

interval

a character that specifies the type of interval calculation.

level

confidence level for calculating confidence intervals. Default is 0.95.

...

further arguments, currently not used.

Details

For reestim = TRUE (default), the formulas form Dubrule (1983) are used. These enable a faster calculation of the leave-one-out prediction and the associated standard deviation, especially for a large number of observations. However, with few observations, the re-estimated regression coefficients may differ considerably from those based on the entire data set. Note that the process variance and correlation parameters are not re-estimated.

Value

The loo method of class "gekm" returns a vector of leave-one-out predictions, if sd.fit = FALSE and interval = "none". As with predict.gekm, setting sd.fit = FALSE and interval = "confidence" generates a matrix with the leave-one-out predicted values and the lower and upper limits of the confidence intervals. For sd.fit = TRUE, a list with the following components is returned:

fit.loo

either a vector or a matrix, as described above.

sd.loo

leave-one-out predicted standard deviation.

Author(s)

Carmen van Meegen

References

Bachoc, F. (2013). Cross Validation and Maximum Likelihood Estimations of Hyper-parameters of Gaussian Processes with Model Misspecification. Computational Statistics and Data Analysis, 66:55–69. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.csda.2013.03.016")}.

Dubrule, O. (1983). Cross Validation of Kriging in a Unique Neighborhood. Mathematical Geology, 15:687–699. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/BF01033232")}.

Martin, J. D. and Simpson, T. W. (2005). Use of Kriging Models to Approximate Deterministic Computer Models. AIAA Journal, 43(4):853–863. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2514/1.8650")}.

See Also

gekm for fitting a (gradient-enhanced) Kriging model.

predict.gekm for prediction at new data points based on a model of class "gekm".

plot.gekm for plotting the results of a leave-one-out cross-validation.

Examples

## 1-dimensional example: Oakley and O’Hagan (2002)

# Define test function and its gradient 
f <- function(x) 5 + x + cos(x)
fGrad <- function(x) 1 - sin(x)

# Generate coordinates and calculate slopes
x <- seq(-5, 5, length = 5)
y <- f(x)
dy <- fGrad(x)
dat <- data.frame(x, y)
deri <- data.frame(x = dy)

# Fit gradient-enhanced Kriging model
gekm.1d <- gekm(y ~ x, data = dat, deriv = deri, covtype = "gaussian", theta = 1)

# Perform leave-one-out cross-validation
loo(gekm.1d)
loo(gekm.1d, sd.fit = FALSE)
loo(gekm.1d, sd.fit = FALSE, reestim = FALSE)
loo(gekm.1d, sd.fit = TRUE, scale = TRUE)
loo(gekm.1d, sd.fit = TRUE, reestim = FALSE, scale = TRUE)
loo(gekm.1d, sd.fit = FALSE, interval = "confidence")
loo(gekm.1d, sd.fit = TRUE, interval = "confidence")

gek documentation built on Jan. 31, 2026, 1:07 a.m.

Related to loo in gek...