
Non-parametric (Y,T) Bootstrap for selecting the number of components in PLSR models
Source:R/YTplsR.R
nbcomp.bootplsR.Rd
Provides a wrapper for the bootstrap function boot
from the
boot
R package.
Implements non-parametric bootstraps for PLS
Regression models by (Y,T) resampling to select the number of components.
Usage
nbcomp.bootplsR(
Y,
X,
R = 500,
sim = "ordinary",
ncpus = 1,
parallel = "no",
typeBCa = TRUE,
verbose = TRUE
)
Arguments
- Y
Vector of response.
- X
Matrix of predictors.
- R
The number of bootstrap replicates. Usually this will be a single positive integer. For importance resampling, some resamples may use one set of weights and others use a different set of weights. In this case
R
would be a vector of integers where each component gives the number of resamples from each of the rows of weights.- sim
A character string indicating the type of simulation required. Possible values are
"ordinary"
(the default),"balanced"
,"permutation"
, or"antithetic"
.- ncpus
integer: number of processes to be used in parallel operation: typically one would chose this to the number of available CPUs.
- parallel
The type of parallel operation to be used (if any). If missing, the default is taken from the option "boot.parallel" (and if that is not set, "no").
- typeBCa
Compute BCa type intervals ?
- verbose
Display info during the run of algorithm?
Details
More details on bootstrap techniques are available in the help of the
boot
function.
References
A new bootstrap-based stopping criterion in PLS component construction,
J. Magnanensi, M. Maumy-Bertrand, N. Meyer and F. Bertrand (2016), in The Multiple Facets of Partial Least Squares and Related Methods,
doi:10.1007/978-3-319-40643-5_18
A new universal resample-stable bootstrap-based stopping criterion for PLS component construction,
J. Magnanensi, F. Bertrand, M. Maumy-Bertrand and N. Meyer, (2017), Statistics and Computing, 27, 757–774.
doi:10.1007/s11222-016-9651-4
New developments in Sparse PLS regression, J. Magnanensi, M. Maumy-Bertrand,
N. Meyer and F. Bertrand, (2021), Frontiers in Applied Mathematics and Statistics,
doi:10.3389/fams.2021.693126
.
Author
Jérémy Magnanensi, Frédéric Bertrand
frederic.bertrand@lecnam.net
https://fbertran.github.io/homepage/
Examples
data(pine, package="plsRglm")
Xpine<-pine[,1:10]
ypine<-log(pine[,11])
res <- nbcomp.bootplsR(ypine, Xpine)
#> [1] 1
#> ____************************************************____
#> ____Component____ 1 ____
#> ____Predicting X without NA neither in X nor in Y____
#> ****________________________________________________****
#>
#> [1] 2
#> ____************************************************____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Predicting X without NA neither in X nor in Y____
#> ****________________________________________________****
#>
#> [1] 3
#> ____************************************************____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Predicting X without NA neither in X nor in Y____
#> ****________________________________________________****
#>
#> [1] "Optimal number of components: K = 2"
nbcomp.bootplsR(ypine, Xpine, typeBCa=FALSE)
#> [1] 1
#> ____************************************************____
#> ____Component____ 1 ____
#> ____Predicting X without NA neither in X nor in Y____
#> ****________________________________________________****
#>
#> [1] 2
#> ____************************************************____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Predicting X without NA neither in X nor in Y____
#> ****________________________________________________****
#>
#> [1] 3
#> ____************************************************____
#> ____Component____ 1 ____
#> ____Component____ 2 ____
#> ____Component____ 3 ____
#> ____Predicting X without NA neither in X nor in Y____
#> ****________________________________________________****
#>
#> [1] "Optimal number of components: K = 2"
#> [1] 2
# \donttest{
nbcomp.bootplsR(ypine, Xpine, typeBCa=FALSE, verbose=FALSE)
#> [1] 2
try(nbcomp.bootplsR(ypine, Xpine, sim="permutation"))
#> [1] 1
#> ____************************************************____
#> ____Component____ 1 ____
#> ____Predicting X without NA neither in X nor in Y____
#> ****________________________________________________****
#>
#> Error in bca.ci(boot.out, conf, index[1L], L = L, t = t.o, t0 = t0.o, :
#> estimated adjustment 'w' is infinite
nbcomp.bootplsR(ypine, Xpine, sim="permutation", typeBCa=FALSE)
#> [1] 1
#> ____************************************************____
#> ____Component____ 1 ____
#> ____Predicting X without NA neither in X nor in Y____
#> ****________________________________________________****
#>
#> [1] "Optimal number of components: K = 0"
#> [1] 0
# }