mlr.orthogonalize {MatchLinReg} | R Documentation |
Orthogonalization of vectors with repsect to a matrix
Description
Decomposing a collection of vectors into parallel and orthogonal components with respect to the subspace spanned by columns of a reference matrix.
Usage
mlr.orthogonalize(X, Z, normalize = FALSE, tolerance = .Machine$double.eps^0.5)
Arguments
X |
Matrix whose columns form the subspace, with respect to which we want to orthogonalize columns of |
Z |
Matrix whose columns we want to orthogonalize with respect to the subpsace spanned by columns of |
normalize |
Boolean flag, indicating whether the orthogonal component of |
tolerance |
If unnormalized projection of a column of |
Details
Current implementation uses Singular Value Decomposition (svd
) of X
to form an orthonormal basis from columns of X
to facilitate the projection process.
Value
A matrix of same dimensions as Z
is returned, with each column containing the orthogonal component of the corresponding column of Z
. Parallel components are attached as parallel
attribute.
Author(s)
Alireza S. Mahani, Mansour T.A. Sharabiani
References
Link to a draft paper, documenting the supporting mathematical framework, will be provided in the next release.
Examples
K <- 10
N <- 100
Ko <- 5
X <- matrix(runif(N*K), ncol = K)
Z <- matrix(runif(N*Ko), ncol = Ko)
ret <- mlr.orthogonalize(X = X, Z = Z, normalize = FALSE)
orthogonal <- ret
parallel <- attr(ret, "parallel")
Z.rec <- parallel + orthogonal
# check that parallel and orthogonal components add up to Z
cat("check 1:", all.equal(as.numeric(Z.rec), as.numeric(Z)), "\n")
# check that inner product of orthogonal columns and X columns are zero
cat("check 2:", all.equal(t(orthogonal) %*% X, matrix(0, nrow = Ko, ncol = K)), "\n")