cv_choose: Cross-validation choice

View source: R/cv_choose.R

cv_chooseR Documentation

Cross-validation choice

Description

Extracting the CV choices of SPCR parameters.

Usage

cv_choose(scor, scor_lwr, scor_upr, K, fit_measure)

Arguments

scor

npcs \times nthrs matrix of K-fold CV scores

scor_lwr

npcs \times nthrs matrix of score lower bounds

scor_upr

npcs \times nthrs matrix of score upper bounds

K

numeric vector of length 1 storing the number of folds for the K-fold cross-validation procedure

fit_measure

character vector of length 1 indicating the type of fit measure to be used in the to cross-validation procedure

Details

Given a matrix of npcs \times nthrs, returns the best choice based on the type of fit measure (best overall and 1se rule versions.) This function returns as solutions:

  • default: the best choice based on the given fit measure (e.g. highest likelihood ratio test statistic, lowest BIC)

  • oneSE: the solution that defined the most parsimonious model within 1 standard error from the best one. When both the number of components and the threshold parameter are cross-validated, the 1-standard error rule finds the candidate alternative solutions using the lowest number of PCs and having the best fit-measure. This decision is guided by the desire to counterbalance the tendency of GSPCR of selecting the highest number of components available when using cross-validation.

Value

A list of two numeric vectors:

  • default: numeric vector of length 2 that reports the coordinates in scor defining the default solution.

  • oneSE: numeric vector of length 2 that reports the coordinates for scor defining the solution based on the one standard error rule

Author(s)

Edoardo Costantini, 2023

Examples

# Score matrices
scor <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, ncol = 2)
scor_lwr <- matrix(c(1, 2, 3, 4, 5, 6) - 1.5, nrow = 3, ncol = 2)
scor_upr <- matrix(c(1, 2, 3, 4, 5, 6) + 1.5, nrow = 3, ncol = 2)

# Number of folds
K <- 10

# Type of fit_measure
fit_measure <- "F"

# Use the function
cv_choose(scor, scor_lwr, scor_upr, K, fit_measure)


gspcr documentation built on May 29, 2024, 2:44 a.m.