computeResidualMatrix {EESPCA}R Documentation

Calculates the residual matrix from the reduced rank reconstruction

Description

Utility function for computing the residual matrix formed by subtracting from X a reduced rank approximation of matrix X generated from the top k principal components contained in matrix V.

Usage

    computeResidualMatrix(X,V,center=TRUE)

Arguments

X

An n-by-p data matrix whose top k principal components are contained in the p-by-k matrix V.

V

A p-by-k matrix containing the loadings for the top k principal components of X.

center

If true (the default), X will be mean-centered before the residual matrix is computed. If the PCs in V were computed via SVD on a mean-centered matrix or via eigen-decomposition of the sample covariance matrix, this should be set to true.

Value

Residual matrix.

Examples

    set.seed(1)
    # Simulate 10x5 MVN data matrix
    X=matrix(rnorm(50), nrow=10)
    # Perform PCA
    prcomp.out = prcomp(X)
    # Get rank 2 residual matrix
    computeResidualMatrix(X=X, V=prcomp.out$rotation[,1:2])

[Package EESPCA version 0.7.0 Index]