blockscal | R Documentation |
Function blockscal
autoscales the blocks (i.e. sets of columns) of a reference (= training) matrix and eventually a new (= test) matrix, and concatenates the scaled blocks into two new output matrices.
Each block of the reference matrix is scaled by its "norm", i.e. the square root of the sum of the variances of each column of the block. The blocks of the test matrix are scaled by the norms of the blocks of the reference matrix.
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 "...
").
Outputs Xr
and Xu
of blockscal
can be used as inputs of functions such as pls
(= MB-PLS), plsr
(= MB-PLSR), etc.
blockscal(Xr, Xu = NULL, blocks, colblocks = NULL, weights = NULL)
Xr |
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 |
weights |
A vector of length |
Xr |
A matrix with the concatenated scaled blocks from |
Xu |
A matrix with the concatenated scaled blocks 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("v", 1:p, sep = "")
set.seed(NULL)
X
blocks <- list(1:2, 4, 6:8)
blocks
res <- blockscal(X[1:3, ], X[4:5, ], blocks)
res
blockscal(res$Xr, blocks = res$blocks)
blockscal(X[1:3, ], X[4:5, ], colblocks = c(rep(1, 3), rep(2, 7)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.