Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pca_OADP_proj

OADP projection


Description

Online Augmentation, Decomposition, and Procrustes (OADP) projection of PC loadings onto some study data X.

Usage

pca_OADP_proj(X, loadings, sval)

pca_OADP_proj2(XV, X_norm, sval)

Arguments

X

Data to get PC loadings into.

loadings

PC loadings of the reference PCA to project.

sval

Singular values of the reference PCA (sqrt of the eigen values). Only the ncol(loadings) first ones will be used.

XV

X %*% loadings

X_norm

Vector of sums of squared rows (e.g. rowSums(X^2)).

Value

  • pca_OADP_proj(): A list with the simple projection X %*% loadings and the projection based on OADP.

  • pca_OADP_proj2(): The projection based on OADP only (a matrix of same size of XV).

Examples

X <- readRDS(system.file("testdata", "three-pops.rds", package = "bigutilsr"))
N <- 400; M <- ncol(X)
ind <- sample(nrow(X), N)

# Compute SVD using one part of samples
svd <- svds(X[ind, ], k = 5)
U <- sweep(svd$u, 2, svd$d, '*')
col <- 2:3
plot(U[, col])
points(cbind(0, 0), pch = 8, col = "green", cex = 2)

# Projecting other samples
proj <- pca_OADP_proj(X = X[-ind, ], loadings = svd$v, sval = svd$d)
points(proj$simple_proj[, col], col = "red", pch = 20)     # shrunk towards 0
points(proj$OADP_proj[, col], col = "blue", pch = 20)      # unshrunk

bigutilsr

Utility Functions for Large-scale Data

v0.3.4
GPL-3
Authors
Florian Privé [aut, cre]
Initial release
2021-04-08

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.