This package provides efficient implementations of cross-validationtechniques for linear and ridge regression models, leveraging C++ codewith Rcpp, RcppParallel, and Eigen libraries. It supports leave-one-out,generalized, and K-fold cross-validation methods, utilizing Eigenmatrices for high performance.
This code is adapted and extended from various sources, leveragingthe capabilities of the following:
Please refer to the source files for detailed information andlicenses.
This code is underMIT License.
library(cvLM)data(mtcars)n<-nrow(mtcars)# Formula methodcvLM( mpg~ .,data = mtcars,K.vals = n,# Leave-one-out CVlambda =10# Shrinkage parameter of 10)# lm methodmy.lm<-lm(mpg~ .,data = mtcars)cvLM( my.lm,data = mtcars,K.vals =c(5L, 8L),# Perform both 5- and 8-fold CVn.threads = 8L,# Allow up to 8 threads for computationseed = 1234L)# glm methodmy.glm<-glm(mpg~ .,data = mtcars)cvLM( my.glm,data = mtcars,K.vals = n,generalized =TRUE# Use generalized CV)