For (a grid of) values for a
, nx
and ny
, loocv
estimates the prediction error using k-fold CV.
loocv(
X,
Y,
a = 1:2,
a2 = 1,
b2 = 1,
fitted_model = NULL,
func = o2m,
app_err = F,
kcv,
stripped = TRUE,
p_thresh = 3000,
q_thresh = p_thresh,
tol = 1e-10,
max_iterations = 100,
seed = "off"
)
List with two numeric vectors:
Contains the k-fold CV estimated RMSEP
Contains the apparent error
Numeric matrix. Vectors will be coerced to matrix with as.matrix
(if this is possible)
Numeric matrix. Vectors will be coerced to matrix with as.matrix
(if this is possible)
Vector of integers. Contains the numbers of joint components.
Vector of integers. Contains the numbers of orthogonal components in \(X\).
Vector of integers. Contains the numbers of orthogonal components in \(Y\).
List. Deprecated. O2PLS model fit with o2m
. Is used to calculate the apparent error without recalculating this fit.
Function to fit the O2PLS model with. Only o2m
and o2m_stripped
are supported.
Logical. Deprecated. Should the apparent error also be computed?
Integer. The value of \(k\), i.e. the number of folds. Choose \(N\) for LOO-CV.
Logical. Use the stripped version of o2m (usually when cross-validating)?
Integer. If X
has more than p_thresh
columns, a power method optimization is used, see o2m2
Integer. If Y
has more than q_thresh
columns, a power method optimization is used, see o2m2
Double. Threshold for which the NIPALS method is deemed converged. Must be positive.
Integer. Maximum number of iterations for the NIPALS method.
Integer. A random seed to make the analysis reproducible.
Note that this function can be easily parallelized (on Windows e.g. with the parallel
package.).
The parameters a
, a2
and b2
can be integers or vectors of integers. A for loop is used to loop over all combinations.
The resulting output is a list, which is more easy to interpret if you use array(unlist(output_of_loocv$CVerr))
as in the example below.
The array wil have varying a
along the first dimension and a2
and b2
along the second and third respectively.
Typing example(loocv)
(hopefully) clarifies this function.