Skip to contents

Convenience wrapper that calls svd_project followed by svd_reconstruct, yielding the rank-k least-squares approximation of Y in the column space of the original matrix.

Usage

pca_coef(factor, Y)

Arguments

factor

An amSVD object from svd_factor.

Y

Numeric matrix or vector to project and reconstruct. Must have nrow(Y) equal to the number of rows of the original source matrix.

Value

Numeric matrix with the same dimensions as Y, containing the rank-k approximation.

Examples

m <- matrix(rnorm(30), nrow = 6)
A <- adgeMatrix(m)
fac <- svd_factor(A, k = 2L)
approx <- pca_coef(fac, m)