Skip to contents

Draw bootstrap replicates of a fitted PLS model, refitting on each resample.

Usage

pls_bootstrap(
  X,
  Y,
  ncomp,
  R = 100L,
  algorithm = c("simpls", "nipals", "kernelpls", "widekernelpls"),
  backend = "arma",
  conf = 0.95,
  seed = NULL,
  type = c("xy", "xt"),
  parallel = c("none", "future"),
  future_seed = TRUE,
  return_scores = FALSE,
  ...
)

Arguments

X

Predictor matrix.

Y

Response matrix or vector.

ncomp

Number of components.

R

Number of bootstrap replications.

algorithm

Backend algorithm ("simpls", "nipals", "kernelpls" or "widekernelpls").

backend

Backend argument passed to the fitting routine.

conf

Confidence level.

seed

Optional seed.

type

Character; bootstrap scheme, e.g. "pairs", "residual", or "parametric".

parallel

Logical or character; if TRUE or one of c("sequential", "multisession", "multicore"), uses the future framework.

future_seed

Logical or integer; forwarded to future.seed for reproducible parallel streams.

return_scores

Logical; if TRUE, return component scores for each replicate (may be large).

...

Additional arguments forwarded to pls_fit().

Value

A list with bootstrap estimates and summaries.

Examples

set.seed(123)
X <- matrix(rnorm(60), nrow = 20)
y <- X[, 1] - 0.5 * X[, 2] + rnorm(20, sd = 0.1)
pls_bootstrap(X, y, ncomp = 2, R = 20)
#> $mean
#>            [,1]
#> [1,]  0.9913106
#> [2,] -0.4513641
#> [3,] -0.0364948
#> 
#> $lower
#>            [,1]
#> [1,]  0.9008479
#> [2,] -0.5554312
#> [3,] -0.1578291
#> 
#> $upper
#>             [,1]
#> [1,]  1.04643103
#> [2,] -0.29747912
#> [3,]  0.03218767
#> 
#> $samples
#> $samples[[1]]
#>             [,1]
#> [1,]  1.01370235
#> [2,] -0.47362869
#> [3,] -0.01871238
#> 
#> $samples[[2]]
#>             [,1]
#> [1,]  1.00805220
#> [2,] -0.29373547
#> [3,] -0.03438166
#> 
#> $samples[[3]]
#>             [,1]
#> [1,]  1.02482494
#> [2,] -0.43981055
#> [3,] -0.06598034
#> 
#> $samples[[4]]
#>            [,1]
#> [1,]  0.9217837
#> [2,] -0.4195667
#> [3,] -0.1675766
#> 
#> $samples[[5]]
#>             [,1]
#> [1,]  0.90088847
#> [2,] -0.56898923
#> [3,] -0.06228952
#> 
#> $samples[[6]]
#>             [,1]
#> [1,]  1.03738707
#> [2,] -0.48335047
#> [3,]  0.02431306
#> 
#> $samples[[7]]
#>             [,1]
#> [1,]  1.03665669
#> [2,] -0.41794678
#> [3,] -0.01365786
#> 
#> $samples[[8]]
#>             [,1]
#> [1,]  0.90081111
#> [2,] -0.53015677
#> [3,] -0.06947427
#> 
#> $samples[[9]]
#>              [,1]
#> [1,]  1.046587228
#> [2,] -0.420771928
#> [3,]  0.006859411
#> 
#> $samples[[10]]
#>            [,1]
#> [1,]  1.0205916
#> [2,] -0.3137173
#> [3,] -0.0397945
#> 
#> $samples[[11]]
#>             [,1]
#> [1,]  1.04625839
#> [2,] -0.46446341
#> [3,]  0.00655102
#> 
#> $samples[[12]]
#>            [,1]
#> [1,]  0.9487480
#> [2,] -0.5126467
#> [3,] -0.1244670
#> 
#> $samples[[13]]
#>             [,1]
#> [1,]  0.96695471
#> [2,] -0.52643057
#> [3,] -0.01118588
#> 
#> $samples[[14]]
#>             [,1]
#> [1,]  1.00591617
#> [2,] -0.51301573
#> [3,]  0.03150559
#> 
#> $samples[[15]]
#>             [,1]
#> [1,]  1.00430562
#> [2,] -0.49498888
#> [3,] -0.03036961
#> 
#> $samples[[16]]
#>              [,1]
#> [1,]  1.006820717
#> [2,] -0.490124440
#> [3,]  0.006203915
#> 
#> $samples[[17]]
#>            [,1]
#> [1,]  1.0193070
#> [2,] -0.3016168
#> [3,] -0.1470557
#> 
#> $samples[[18]]
#>            [,1]
#> [1,]  0.9601683
#> [2,] -0.5404460
#> [3,] -0.0334001
#> 
#> $samples[[19]]
#>             [,1]
#> [1,]  0.99306219
#> [2,] -0.51709589
#> [3,] -0.01978846
#> 
#> $samples[[20]]
#>             [,1]
#> [1,]  0.96338505
#> [2,] -0.30477937
#> [3,]  0.03280478
#> 
#> 
#> $type
#> [1] "xy"
#> 
#> $base_fit
#> $coefficients
#>             [,1]
#> [1,]  1.01956855
#> [2,] -0.45295054
#> [3,] -0.01325522
#> 
#> $intercept
#> [1] -0.01093997
#> 
#> $x_weights
#>             [,1]        [,2]
#> [1,]  0.20997486  0.04194897
#> [2,] -0.08441327 -0.08227311
#> [3,] -0.03572358  0.23617705
#> 
#> $x_loadings
#>           [,1]       [,2]
#> [1,]  3.972259  0.3468121
#> [2,] -1.452865 -0.7870847
#> [3,] -1.211650  3.8983283
#> 
#> $y_loadings
#>          [,1]     [,2]
#> [1,] 4.724127 0.658436
#> 
#> $x_means
#> [1]  0.14162380 -0.05125716  0.10648523
#> 
#> $y_means
#> [1] 0.1552607
#> 
#> $ncomp
#> [1] 2
#> 
#> $mode
#> [1] "pls1"
#> 
#> $algorithm
#> [1] "simpls"
#> 
#> $x_center
#> [1]  0.14162380 -0.05125716  0.10648523
#> 
#> $y_center
#> [1] 0.1552607
#> 
#> $X
#>              [,1]        [,2]        [,3]
#>  [1,] -0.56047565 -1.06782371 -0.69470698
#>  [2,] -0.23017749 -0.21797491 -0.20791728
#>  [3,]  1.55870831 -1.02600445 -1.26539635
#>  [4,]  0.07050839 -0.72889123  2.16895597
#>  [5,]  0.12928774 -0.62503927  1.20796200
#>  [6,]  1.71506499 -1.68669331 -1.12310858
#>  [7,]  0.46091621  0.83778704 -0.40288484
#>  [8,] -1.26506123  0.15337312 -0.46665535
#>  [9,] -0.68685285 -1.13813694  0.77996512
#> [10,] -0.44566197  1.25381492 -0.08336907
#> [11,]  1.22408180  0.42646422  0.25331851
#> [12,]  0.35981383 -0.29507148 -0.02854676
#> [13,]  0.40077145  0.89512566 -0.04287046
#> [14,]  0.11068272  0.87813349  1.36860228
#> [15,] -0.55584113  0.82158108 -0.22577099
#> [16,]  1.78691314  0.68864025  1.51647060
#> [17,]  0.49785048  0.55391765 -1.54875280
#> [18,] -1.96661716 -0.06191171  0.58461375
#> [19,]  0.70135590 -0.30596266  0.12385424
#> [20,] -0.47279141 -0.38047100  0.21594157
#> 
#> attr(,"class")
#> [1] "big_plsr" "list"    
#> 
#> $bca_lower
#>            [,1]
#> [1,]  0.9569592
#> [2,] -0.5388344
#> [3,] -0.1286506
#> 
#> $bca_upper
#>             [,1]
#> [1,]  1.04658723
#> [2,] -0.29373547
#> [3,]  0.03280478
#> 
#> $jackknife
#>             [,1]        [,2]       [,3]         [,4]         [,5]         [,6]
#> [1,]  1.02017326  1.01810673  1.0157243  1.022873634  1.022063121  1.006261044
#> [2,] -0.45607710 -0.45505536 -0.4721037 -0.447478457 -0.450290543 -0.459143899
#> [3,] -0.01054496 -0.01446393 -0.0163173 -0.007862433 -0.008440752 -0.001161789
#>             [,7]        [,8]       [,9]        [,10]       [,11]       [,12]
#> [1,]  1.02218562  1.01821092  1.0298271  1.033548831  1.02008830  1.02213589
#> [2,] -0.44599976 -0.46178303 -0.4318445 -0.451637856 -0.46045832 -0.45635818
#> [3,] -0.01287389 -0.01462013 -0.0257894  0.001207447 -0.01504661 -0.01400757
#>            [,13]        [,14]       [,15]       [,16]       [,17]       [,18]
#> [1,]  1.02077655  1.018276698  1.01973985  0.97161991  1.02227656  0.99412356
#> [2,] -0.45207275 -0.453293180 -0.43544349 -0.51802509 -0.44269325 -0.48281199
#> [3,] -0.01111254 -0.005173051 -0.01309007 -0.03708979 -0.02380684 -0.01061448
#>            [,19]       [,20]
#> [1,]  1.01867452  1.01955556
#> [2,] -0.45201139 -0.45425090
#> [3,] -0.01344972 -0.01466117
#>