R/kfolds2Pressind.R
kfolds2Pressind.Rd
This function computes individual PRESS for k-fold cross validated partial least squares regression models.
kfolds2Pressind(pls_kfolds)
a k-fold cross validated partial least squares regression model
Individual Press vs number of components for the first group partition
...
Individual Press vs number of components for the last group partition
Use cv.plsR
to create k-fold cross validated partial
least squares regression models.
Nicolas Meyer, Myriam Maumy-Bertrand et Frédéric Bertrand (2010). Comparing the linear and the logistic PLS regression with qualitative predictors: application to allelotyping data. Journal de la Societe Francaise de Statistique, 151(2), pages 1-18. http://publications-sfds.math.cnrs.fr/index.php/J-SFdS/article/view/47
kfolds2coeff
, kfolds2Press
,
kfolds2Mclassedind
and kfolds2Mclassed
to
extract and transforms results from k-fold cross validation.
data(Cornell)
XCornell<-Cornell[,1:7]
yCornell<-Cornell[,8]
kfolds2Pressind(cv.plsR(object=yCornell,dataX=data.frame(scale(as.matrix(XCornell))[,]),
nt=6,K=12,NK=1))
#> NK: 1
#> Leave One Out
#> Number of groups : 12
#> 1
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 2
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 3
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 4
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 5
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 6
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 7
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 8
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 9
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 10
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 11
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> Warning : 1 2 3 4 5 6 7 < 10^{-12}
#> Warning only 5 components could thus be extracted
#> ****________________________________________________****
#>
#> 12
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> [[1]]
#> [[1]][[1]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 1 24.52456 19.46751 9.132702 6.212796 6.260403 6.294375
#>
#> [[1]][[2]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 2 4.124502 0.6664187 0.4453306 0.0288125 0.468846 0.6001117
#>
#> [[1]][[3]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 3 1.551301 0.9608429 1.224441 2.534867 1.991568 5.504755
#>
#> [[1]][[4]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 4 12.26717 0.247437 0.001516247 0.111019 0.06429773 0.05142279
#>
#> [[1]][[5]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 5 4.315406 9.872769 2.420394 4.187705 8.869722 8.95432
#>
#> [[1]][[6]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 6 6.209332 5.820357 3.366519 1.798485 0.950924 1.959007
#>
#> [[1]][[7]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 7 0.08812214 0.4818875 0.2496785 0.2425807 0.00951357 0.008071516
#>
#> [[1]][[8]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 8 0.9442012 0.5163166 0.4084427 0.351376 0.248757 0.2347731
#>
#> [[1]][[9]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 9 0.2203272 0.01149677 0.02486984 0.02827224 0.1233742 0.1658223
#>
#> [[1]][[10]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 10 0.6034613 0.0005521844 0.006299065 0.01764824 0.006014414 0.02841849
#>
#> [[1]][[11]]
#> [,1] [,2] [,3] [,4] [,5]
#> 11 0.8275623 0.01285346 0.6440788 0.7149959 0.06577128
#>
#> [[1]][[12]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> 12 0.03180524 3.374303 2.349701 5.013846 5.458814 8.13772
#>
#>
kfolds2Pressind(cv.plsR(object=yCornell,dataX=data.frame(scale(as.matrix(XCornell))[,]),
nt=6,K=6,NK=1))
#> NK: 1
#> Number of groups : 6
#> 1
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 2
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 3
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> Warning : 1 2 3 4 5 6 7 < 10^{-12}
#> Warning only 5 components could thus be extracted
#> ****________________________________________________****
#>
#> 4
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 5
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> 6
#> ____************************************************____
#> ____Predicting X without NA neither in X nor in Y____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Component____ 4 ____
#> ____Component____ 5 ____
#> ____Component____ 6 ____
#> ****________________________________________________****
#>
#> [[1]]
#> [[1]][[1]]
#> [1] 24.451307 18.523423 9.180100 6.193589 6.229356 6.282449
#>
#> [[1]][[2]]
#> [1] 9.911673 4.328677 5.324334 2.907517 2.102703 8.328408
#>
#> [[1]][[3]]
#> [1] 6.5466802 0.5401274 0.8413098 0.7364706 0.6230485
#>
#> [[1]][[4]]
#> [1] 0.6061007 3.8188152 2.5235164 5.1573527 5.5295224 8.3418423
#>
#> [[1]][[5]]
#> [1] 1.6344038 1.6120430 1.0647803 0.9967819 0.4227701 0.4138761
#>
#> [[1]][[6]]
#> [1] 24.18240 17.71922 11.66697 15.58262 16.77456 17.67640
#>
#>
rm(list=c("XCornell","yCornell"))
# \donttest{
data(pine)
Xpine<-pine[,1:10]
ypine<-pine[,11]
kfolds2Pressind(cv.plsR(object=ypine,dataX=Xpine,nt=10,NK=1,verbose=FALSE))
#> [[1]]
#> [[1]][[1]]
#> [1] 2.964897 2.207253 1.483131 1.801320 1.966935 2.132968 2.260968 2.287074
#> [9] 2.144622 2.217458
#>
#> [[1]][[2]]
#> [1] 4.241709 4.792967 4.212173 5.152223 6.058564 6.266634 6.560632 6.639263
#> [9] 6.660202 6.645264
#>
#> [[1]][[3]]
#> [1] 1.8093264 1.5718043 1.4383122 1.2848013 0.7386009 0.7385485 0.8641779
#> [8] 0.8719031 1.2960630 1.3170951
#>
#> [[1]][[4]]
#> [1] 3.246020 2.360267 2.293529 2.134702 1.933669 1.919261 2.348115 2.395710
#> [9] 2.582932 3.300338
#>
#> [[1]][[5]]
#> [1] 1.0898928 1.2947402 1.0432009 0.8991481 0.7182694 0.6073640 0.7054172
#> [8] 0.7747064 0.9848815 1.0379038
#>
#>
kfolds2Pressind(cv.plsR(object=ypine,dataX=Xpine,nt=10,NK=2,verbose=FALSE))
#> [[1]]
#> [[1]][[1]]
#> [1] 1.735143 2.171985 2.720235 2.687120 2.992445 2.778346 2.814677 2.835605
#> [9] 2.725594 2.668106
#>
#> [[1]][[2]]
#> [1] 2.644537 2.281267 1.308558 1.263651 1.605414 1.567315 1.537378 1.444239
#> [9] 1.427673 1.414822
#>
#> [[1]][[3]]
#> [1] 8.133432 7.082237 5.028216 5.216666 5.379546 5.494992 5.379098 5.389158
#> [9] 5.371497 5.360924
#>
#> [[1]][[4]]
#> [1] 1.613606 2.463037 2.896161 2.182090 1.437190 1.411864 1.518346 1.663396
#> [9] 1.583901 1.599943
#>
#> [[1]][[5]]
#> [1] 0.5939061 1.9770865 1.8420452 2.2813924 2.3148769 2.3034000 2.4065708
#> [8] 2.4820548 2.8240871 2.8193472
#>
#>
#> [[2]]
#> [[2]][[1]]
#> [1] 2.3744934 1.8809548 1.0176573 1.0609831 0.9662159 1.0532217 1.0828194
#> [8] 1.0302945 0.9985391 0.9833061
#>
#> [[2]][[2]]
#> [1] 5.264579 5.529840 4.807801 4.694577 4.805896 4.914530 4.936372 6.933715
#> [9] 6.961489 6.958521
#>
#> [[2]][[3]]
#> [1] 3.733612 2.469846 2.122213 1.640792 1.834893 1.924049 1.862746 1.872219
#> [9] 1.929649 1.939791
#>
#> [[2]][[4]]
#> [1] 1.0999813 1.5172829 1.1492634 0.7116202 0.7897723 0.7053041 0.6910641
#> [8] 0.6800856 0.6827072 0.7115844
#>
#> [[2]][[5]]
#> [1] 1.469224 2.687583 3.125991 3.696002 4.306051 4.750130 4.874952 4.924391
#> [9] 5.061138 4.978049
#>
#>
XpineNAX21 <- Xpine
XpineNAX21[1,2] <- NA
kfolds2Pressind(cv.plsR(object=ypine,dataX=XpineNAX21,nt=10,NK=1,verbose=FALSE))
#> [[1]]
#> [[1]][[1]]
#> [1] 2.498912 1.887336 11.030541 5.764305 7.247899 4.422826 6.296516
#> [8] 5.247029 50.848662
#>
#> [[1]][[2]]
#> [1] 1.284983 1.629335 1.456022 1.497422 1.429474 1.399515 1.673322 1.745843
#> [9] 1.841707
#>
#> [[1]][[3]]
#> [1] 6.719655 6.482266 6.141645 4.724067 4.530756 4.379797 4.571010 4.636038
#> [9] 4.391791
#>
#> [[1]][[4]]
#> [1] 1.5901430 1.3489558 1.2129402 0.7620522 0.7081390 0.6886472 0.7229483
#> [8] 0.7507997 1.3435619
#>
#> [[1]][[5]]
#> [1] 1.538821 2.250934 2.723813 1.781942 1.622303 1.576421 1.530872 2.234774
#> [9] 2.264863
#>
#>
kfolds2Pressind(cv.plsR(object=ypine,dataX=XpineNAX21,nt=10,NK=2,verbose=FALSE))
#> [[1]]
#> [[1]][[1]]
#> [1] 4.369885 4.496571 4.954402 4.386307 3.127353 1.922635 1.915611 1.873252
#> [9] 1.872394
#>
#> [[1]][[2]]
#> [1] 1.776013 1.889223 1.485983 1.350196 1.299602 1.149735 1.158632 1.158409
#> [9] 1.120199
#>
#> [[1]][[3]]
#> [1] 5.552566 4.889075 6.508729 7.902198 5.145554 3.517803 3.428431 3.761803
#> [9] 3.512820
#>
#> [[1]][[4]]
#> [1] 1.787246 1.722403 1.819873 1.286355 1.326539 1.347091 1.485520 1.499576
#> [9] 2.108458
#>
#> [[1]][[5]]
#> [1] 1.221870 2.238274 3.014279 2.999278 2.816852 2.660447 2.623867 2.901496
#> [9] 2.899034
#>
#>
#> [[2]]
#> [[2]][[1]]
#> [1] 2.436478 2.964227 2.429494 1.577833 1.514119 1.351234 1.673747 1.585898
#> [9] 1.969437
#>
#> [[2]][[2]]
#> [1] 5.958402 5.480624 5.687723 4.367798 4.164992 3.939348 3.987328 4.163698
#> [9] 3.872301
#>
#> [[2]][[3]]
#> [1] 4.414010 4.084218 4.175265 3.488151 3.325595 3.235892 3.221994 3.410150
#> [9] 3.654420
#>
#> [[2]][[4]]
#> [1] 0.9607876 2.1601137 3.0264203 2.8096742 2.8892654 3.0763331 3.0059109
#> [8] 2.9666418 3.4780300
#>
#> [[2]][[5]]
#> [1] 1.8574416 2.1957331 0.8374012 1.9929000 0.6326396 3.2009779 3.4275348
#> [8] 37.8751604 1.1566856
#>
#>
rm(list=c("Xpine","XpineNAX21","ypine"))
# }