backtransformAffine.matrix {aroma.light} | R Documentation |
Reverse affine transformation.
## S3 method for class 'matrix': backtransformAffine(X, a=NULL, b=NULL, project=FALSE, ...)
X |
An NxK matrix containing data to be backtransformed. |
a |
A scalar, vector , a matrix , or a list .
First, if a list , it is assumed to contained the elements a
and b , which are the used as if they were passed as seperate
arguments.
If a vector , a matrix of size NxK is created which is then filled
row by row with the values in the vector. Commonly, the
vector is of length K, which means that the matrix will consist of
copies of this vector stacked on top of each other.
If a matrix , a matrix of size NxK is created which is then filled
column by column with the values in the matrix (collected
column by column. Commonly, the matrix is of size NxK, or NxL with
L < K and then the resulting matrix consists of copies sitting
next to each other.
The resulting NxK matrix is subtracted from the NxK matrix X .
|
b |
A scalar, vector , a matrix .
A NxK matrix is created from this argument. For details see
argument a .
The NxK matrix X-a is divided by the resulting NxK matrix.
|
project |
returned (K values per data point are returned).
If TRUE , the backtransformed values "(X-a)/b " are projected
onto the line L(a,b) so that all columns
will be identical.
|
... |
Not used. |
The "(X-a)/b
" backtransformed NxK matrix
is returned.
If project
is TRUE
, an Nx1 matrix
is returned, because
all columns are identical anyway.
Missing values remain missing values. If projected, data points that contain missing values are projected without these.
For more information see matrix
.
X <- matrix(1:8, nrow=4, ncol=2) X[2,2] <- NA print(X) # Returns a 4x2 matrix print(backtransformAffine(X, a=c(1,5))) # Returns a 4x2 matrix print(backtransformAffine(X, b=c(1,1/2))) # Returns a 4x2 matrix print(backtransformAffine(X, a=matrix(1:4,ncol=1))) # Returns a 4x2 matrix print(backtransformAffine(X, a=matrix(1:3,ncol=1))) # Returns a 4x2 matrix print(backtransformAffine(X, a=matrix(1:2,ncol=1), b=c(1,2))) # Returns a 4x1 matrix print(backtransformAffine(X, b=c(1,1/2), project=TRUE)) # If the columns of X are identical, and a identity # backtransformation is applied and projected, the # same matrix is returned. X <- matrix(1:4, nrow=4, ncol=3) Y <- backtransformAffine(X, b=c(1,1,1), project=TRUE) print(X) print(Y) stopifnot(sum(X[,1]-Y) <= .Machine$double.eps) # If the columns of X are identical, and a identity # backtransformation is applied and projected, the # same matrix is returned. X <- matrix(1:4, nrow=4, ncol=3) X[,2] <- X[,2]*2; X[,3] <- X[,3]*3; print(X) Y <- backtransformAffine(X, b=c(1,2,3)) print(Y) Y <- backtransformAffine(X, b=c(1,2,3), project=TRUE) print(Y) stopifnot(sum(X[,1]-Y) <= .Machine$double.eps)