genpca: Generalized Principal Components Analysis

View source: R/gpca.R

genpcaR Documentation

Generalized Principal Components Analysis

Description

Compute a PCA in a inner-product space defined by row and column constraint matrices.

Usage

genpca(
  X,
  A = NULL,
  M = NULL,
  ncomp = min(dim(X)),
  preproc = multivarious::center(),
  deflation = FALSE,
  threshold = 1e-06,
  use_cpp = TRUE,
  maxeig = 800,
  warn_approx = TRUE
)

Arguments

X

the data matrix

A

the column constraints. Can be a vector, symmetric matrix, or symmetric sparse matrix with ncol(X) rows and columns.

M

the row constraints. Can be a vector, symmetric matrix, or symmetric sparse matrix with nrow(X) rows and columns.

ncomp

the number of components to return

preproc

a pre-processing function (e.g. center() or standardize() from multivarious package, see Details)

deflation

use the iterative deflation method

threshold

convergence threshold for deflation method

use_cpp

use the C++ implementation

maxeig

upper bound on the dimension used for eigen decompositions. If the dimension of a constraint matrix is at most this value a full eigen decomposition is used. Otherwise only the leading maxeig eigenvalues are computed, yielding an approximate result.

warn_approx

logical; emit a warning when an approximate eigen decomposition is used.

Details

Pre-processing such as scaling and centering is carried out using special functions from the multivarious package. Basic options are multivarious::center(), multivarious::standardize(), and for no pre-processing at all, multivarious::pass(). When method = "eigen", the maxeig parameter controls how eigen decompositions of the constraint matrices are performed. If the dimension of a constraint matrix does not exceed maxeig a full eigen decomposition is used. Otherwise only the leading maxeig eigenvalues and vectors are computed via RSpectra::eigs_sym, producing an approximate result. Set warn_approx = FALSE to suppress the warning about this approximation.

Value

an instance of type genpca, extending bi_projector

References

Abdi, H. (2007). Singular value decomposition (SVD) and generalized singular value decomposition. Encyclopedia of measurement and statistics, 907-912.

Allen, G. I., Grosenick, L., & Taylor, J. (2014). A generalized least-square matrix decomposition. Journal of the American Statistical Association, 109(505), 145-159.

Examples

X <- matrix(rnorm(100*100), 100,100)
A <- cov(X)
M <- cov(t(X))
gp1 <- genpca(X, A=A, M=M, ncomp=100)

Xrecon <- reconstruct(gp1)

gp2 <- truncate(gp1,2)


bbuchsbaum/genpca documentation built on July 16, 2025, 11:03 p.m.