COK_crossval_loo {SpatFD}R Documentation

Leave-One-Out Cross-Validation for Functional cokriging

Description

This function performs leave-one-out cross-validation for functional cokriging. It systematically leaves out one location at a time from the dataset, fits the model to the remaining data, and then makes a prediction for the left-out observation. It is used to assess the predictive performance of the functional cokriging model.

Usage

COK_crossval_loo(object, plot_show, var, show_all)

Arguments

object

A 'COKS_pred' object obtained with function COKS_scores_lambdas.

plot_show

A logical value. If TRUE, the function will generate and display a plot of the cross-validation results. If FALSE, no plot will be displayed. Default is True.

var

A numerical value indicating the number of the variable to be used in the cross-validation. Default is 1.

show_all

A logical value. If TRUE, the function will display all graphs at once, else it will display them one by one. Default is FALSE.

Value

An object containing the results of the leave-one-out cross-validation. Includes:

performance_metrics

Summary statistics describing the overall predictive performance, such as mean squared error.

plots

The generation of plots showing the cross-validation results, controlled by the plot_show parameter. If plot_show is TRUE, this will contain the plots; otherwise, it will be empty.

Author(s)

Venus Puertas vpuertasg@unal.edu.co

References

Bohorquez, M., Giraldo, R., & Mateu, J. (2016). Optimal sampling for spatial prediction of functional data. Statistical Methods & Applications, 25(1), 39-54.

Bohorquez, M., Giraldo, R., & Mateu, J. (2016). Multivariate functional random fields: prediction and optimal sampling. Stochastic Environmental Research and Risk Assessment, 31, pages53–70 (2017).

See Also

recons_fd, KS_scores_lambdas

Examples

# Load the data and the required packages
library(SpatFD)
library(gstat)
data(COKMexico)

# Create the SpatFD data objects
SFD_PM10_NO2 <- SpatFD(Mex_PM10, coords = coord_PM10, basis = "Fourier", 
                       nbasis = 21, lambda = 0.000001, nharm = 2,
                       name = names(Mex_PM10))
SFD_PM10_NO2 <- SpatFD(NO2, coords = coord_NO2, basis = "Fourier", 
                       nbasis = 27, lambda = 0.000001, nharm = 2,
                       add = SFD_PM10_NO2,name = names(NO2))

# Fit the model
model1 <- gstat::vgm(647677.1,"Gau",23317.05)
model1 <- gstat::vgm(127633,"Wav",9408.63, add.to = model1)

# Perform the cokriging
newcoords <- data.frame(x = 509926,y = 2179149)
coks <- COKS_scores_lambdas(SFD_PM10_NO2,newcoords,model1)

# Perform the cross-validation along NO2
COK_crossval_loo(object = coks, var = 2,show_all=TRUE)


[Package SpatFD version 0.0.1 Index]