blockscal {rchemo}R Documentation

Block autoscaling

Description

Functions managing blocks of data.

- blockscal: Autoscales a list of blocks (i.e. sets of columns) of a training X-data, and eventually the blocks of new X-data. The scaling factor (computed on the training) is the "norm" of the block, i.e. the square root of the sum of the variances of each column of the block.

- mblocks: Makes a list of blocks from X-data.

- hconcat: Concatenates horizontally the blocks of a list.

Usage


blockscal(Xtrain, X = NULL, weights = NULL)

mblocks(X, blocks)

hconcat(X)

Arguments

Xtrain

A list of blocks of training X-data

X

For blockscal: A list of blocks of new X-data. For mblocks: X-data. For hconcat: a list of blocks of X-data.

blocks

A list (of same length as the number of blocks) giving the column numbers in X.

weights

Weights (n, 1) to apply to the training observations. Internally, weights are "normalized" to sum to 1. Default to NULL (weights are set to 1 / n).

Value

For mblocks: a list of blocks of X-data.

For hconcat: a matrix concatenating a list of data blocks.

For blockscal:

Xtrain

A list of blocks of training X-data, after block autoscaling.

X

A list of blocks of new X-data, after block autoscaling.

disp

The scaling factor (computed on the training).

Note

The second example is equivalent to MB-PLSR

Examples


n <- 10 ; p <- 10
Xtrain <- matrix(rnorm(n * p), ncol = p)
ytrain <- rnorm(n)
m <- 2

Xtest <- matrix(rnorm(m * p), ncol = p)
colnames(Xtest) <- paste("v", 1:p, sep = "")
Xtrain
Xtest

blocks <- list(1:2, 4, 6:8)
zXtrain <- mblocks(Xtrain, blocks = blocks)
zXtest <- mblocks(Xtest, blocks = blocks)

zXtrain
blockscal(zXtrain, zXtest)

res <- blockscal(zXtrain, zXtest)
hconcat(res$Xtrain)
hconcat(res$X)

## example of equivalence with MB-PLSR

n <- 10 ; p <- 10
Xtrain <- matrix(rnorm(n * p), ncol = p)
ytrain <- rnorm(n)
m <- 2

Xtest <- matrix(rnorm(m * p), ncol = p)
colnames(Xtest) <- paste("v", 1:p, sep = "")
Xtrain
Xtest

blocks <- list(1:2, 4, 6:8)
X1 <- mblocks(Xtrain, blocks = blocks)
X2 <- mblocks(Xtest, blocks = blocks)
res <- blockscal(X1, X2)
zXtrain <- hconcat(res$Xtrain)
zXtest <- hconcat(res$X)

nlv <- 3
fm <- plskern(zXtrain, ytrain, nlv = nlv)
predict(fm, zXtest)


[Package rchemo version 0.1-1 Index]