Skip to contents

Simulate a univariate-response PLS dataset using the Li et al.-style generator available in plsRglm.

Usage

simulate_pls_data(n, p, true_ncomp, seed = NULL, model = "li2002")

Arguments

n

Number of observations.

p

Number of predictors.

true_ncomp

True number of latent components.

seed

Optional random seed. If supplied, it is used only for this call.

model

Simulation model. Only "li2002" is currently supported.

Value

A list with components x, y, data, true_ncomp, seed, and model.

Examples

sim <- simulate_pls_data(n = 20, p = 10, true_ncomp = 2, seed = 42)
str(sim)
#> List of 6
#>  $ x         : num [1:20, 1:10] 10.61 -4.3 -3.1 2.22 -5.9 ...
#>   ..- attr(*, "dimnames")=List of 2
#>   .. ..$ : NULL
#>   .. ..$ : chr [1:10] "x1" "x2" "x3" "x4" ...
#>  $ y         : num [1:20] 17.87 -8.09 -5.92 3.96 -9.97 ...
#>  $ data      :'data.frame':	20 obs. of  11 variables:
#>   ..$ y  : num [1:20] 17.87 -8.09 -5.92 3.96 -9.97 ...
#>   ..$ x1 : num [1:20] 10.61 -4.3 -3.1 2.22 -5.9 ...
#>   ..$ x2 : num [1:20] -2.347 -6.901 -5.568 -1.044 0.317 ...
#>   ..$ x3 : num [1:20] 10.6 -4.26 -3.11 2.24 -5.92 ...
#>   ..$ x4 : num [1:20] -2.335 -6.88 -5.56 -1.059 0.309 ...
#>   ..$ x5 : num [1:20] 4.13 -5.593 -4.351 0.589 -2.795 ...
#>   ..$ x6 : num [1:20] 10.59 -4.28 -3.1 2.24 -5.92 ...
#>   ..$ x7 : num [1:20] -2.326 -6.865 -5.549 -1.059 0.304 ...
#>   ..$ x8 : num [1:20] 10.59 -4.26 -3.11 2.2 -5.91 ...
#>   ..$ x9 : num [1:20] -2.321 -6.881 -5.543 -1.057 0.317 ...
#>   ..$ x10: num [1:20] 4.126 -5.578 -4.334 0.582 -2.796 ...
#>  $ true_ncomp: int 2
#>  $ seed      : int 42
#>  $ model     : chr "li2002"