Naive sparsity control by coefficient thresholding
Examples
set.seed(123)
X <- matrix(rnorm(40), nrow = 10)
y <- X[, 1] - 0.5 * X[, 2] + rnorm(10, sd = 0.1)
fit <- pls_fit(X, y, ncomp = 2)
pls_threshold(fit, threshold = 0.05)
#> $coefficients
#> [,1]
#> [1,] 0.7945827
#> [2,] -0.3874556
#> [3,] 0.1205194
#> [4,] 0.3708827
#>
#> $intercept
#> [1] -0.07729456
#>
#> $x_weights
#> [,1] [,2]
#> [1,] 0.278021666 0.2224039
#> [2,] 0.002259737 -0.2982192
#> [3,] -0.039744939 0.1465173
#> [4,] 0.126996697 0.1076294
#>
#> $x_loadings
#> [,1] [,2]
#> [1,] 2.803684 0.1385679
#> [2,] 1.818750 -2.3265396
#> [3,] -1.468176 1.6845482
#> [4,] 1.244542 0.2652412
#>
#> $y_loadings
#> [,1] [,2]
#> [1,] 1.807709 1.312928
#>
#> $x_means
#> [1] 0.07462564 0.20862196 -0.42455887 0.32204455
#>
#> $y_means
#> [1] -0.03055689
#>
#> $ncomp
#> [1] 2
#>
#> $mode
#> [1] "pls1"
#>
#> $algorithm
#> [1] "simpls"
#>
#> $x_center
#> [1] 0.07462564 0.20862196 -0.42455887 0.32204455
#>
#> $y_center
#> [1] -0.03055689
#>
#> $X
#> [,1] [,2] [,3] [,4]
#> [1,] -0.56047565 1.2240818 -1.0678237 0.42646422
#> [2,] -0.23017749 0.3598138 -0.2179749 -0.29507148
#> [3,] 1.55870831 0.4007715 -1.0260044 0.89512566
#> [4,] 0.07050839 0.1106827 -0.7288912 0.87813349
#> [5,] 0.12928774 -0.5558411 -0.6250393 0.82158108
#> [6,] 1.71506499 1.7869131 -1.6866933 0.68864025
#> [7,] 0.46091621 0.4978505 0.8377870 0.55391765
#> [8,] -1.26506123 -1.9666172 0.1533731 -0.06191171
#> [9,] -0.68685285 0.7013559 -1.1381369 -0.30596266
#> [10,] -0.44566197 -0.4727914 1.2538149 -0.38047100
#>
#> $coef_threshold
#> [1] 0.05
#>
#> attr(,"class")
#> [1] "big_plsr" "list"