blockpls | R Documentation |
Function blockpls
implements a dimension reduction of pre-selected blocks of variables (= set of columns) of a reference (= training) matrix and eventually a new (= test) matrix, by PCA (default) or PLS. The block reduction consists in calculating latent variables (= scores) independently for each block.
The scores calculated for each block for the reference matrix are concatenated into a new output matrix. The same is done for the eventual test scores.
The function allows giving a priori weights to the rows of the reference matrix in the calculations (argument weights
to specify within the optional arguments "...
").
blockpls(Xr, Yr = NULL, Xu = NULL, blocks, colblocks = NULL, ncomp, ...)
Xr |
A |
Yr |
A |
Xu |
A |
blocks |
A list of same length as the number of blocks. Each component of the list gives the column numbers in |
colblocks |
Alternative to using argument |
ncomp |
A list of same length as the number of blocks defining the number of scores to calculate for each block, or a single number. In this last case, the same number of scores is used for all the blocks. |
... |
Other arguments to pass in functions |
Tr |
A matrix with the scores calculated from |
Tu |
A matrix with the scores calculated from |
blocks |
A list of column numbers defining the blocks in the output matrices |
n <- 5 ; p <- 10
set.seed(1)
X <- matrix(rnorm(n * p, mean = 10), ncol = p, byrow = TRUE)
colnames(X) <- paste("Var", 1:p, sep = "")
Y <- matrix(rnorm(n * 2, mean = 10), ncol = 2, byrow = TRUE)
set.seed(NULL)
X
Y
blocks <- list(1:3, 4:6, 7:9)
blocks
res <- blockpls(X[1:3, ], Xu = X[4:5, ], blocks = blocks, ncomp = 2)
#res <- blockpls(X[1:3, ], Xu = X[4:5, ], colblocks = c(rep(1, 3), rep(2, 3), rep(3, 3)), ncomp = 2)
#res <- blockpls(X[1:3, ], Y[1:3, ], X[4:5, ], blocks = blocks, ncomp = c(2, 1, 1))
res
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.