This function calculates the predicted values at each point of the design and gives an estimation of criterion using K-fold cross-validation.
Usage
crossValidation(model, K)
Arguments
model
an output of the modelFit function. This argument is the initial model fitted with all the data.
K
the number of groups into which the data should be split to apply cross-validation
Value
A list with the following components:
Ypred
a vector of predicted values obtained using K-fold cross-validation at the points of the design
Q2
a real which is the estimation of the criterion R2 obtained by cross-validation
folds
a list which indicates the partitioning of the data into the folds
RMSE_CV
RMSE by K-fold cross-validation (see more details below)
MAE_CV
MAE by K-fold cross-validation (see more details below)
In the case of a Kriging model, other components to test the robustess of the procedure are proposed:
theta
the range parameter theta estimated for each fold,
trend
the trend parameter estimated for each fold,
shape
the estimated shape parameter if the covariance structure is of type powerexp.
The principle of cross-validation is to split the data into K folds of approximately equal size A_{1}{A1}, ..., A_{K}{AK}. For k=1 to K, a model Y^(-k) is fitted from the data A1 U ... U AK and this model is validated on the fold Ak. Given a criterion of quality L (here, L could be the RMSE or the MAE criterion), the "evaluation" of the model consists in computing :
Lk = 1/(n/K) Sum (i in Ak) L (yi,Y^(-k)(xi).
The cross-validation criterion is the mean of the K criterion: L_CV1/K (L1+...+LK).
The Q2 criterion is defined as: Q2=code{R2}(code{Y},code{Ypred}) with Y the response value and Ypred the value fit by cross-validation.
Note
When K is equal to the number of observations, leave-one-out cross-validation
is performed.