pca_jg: Crude version of PCA

View source: R/pca_jg.R

pca_jgR Documentation

Crude version of PCA

Description

pca_jg performs a crude PCA given a matrix and the rank of the matrix.

Usage

pca_jg(mat, rank = 1, true_pattern = NULL, cov_method = "complete.obs")

Arguments

mat

The matrix to perform PCA upon.

rank

The rank of the given matrix.

true_pattern

The pattern the matrix was simulated from (optional).

cov_method

The method with which to calculate the covariance matrix. Only relevant when true_pattern is left NULL. Default="complete.obs". See cov. Will likely need to pass "pairwise.complete.obs" for matrices with many missing values.

Value

List containing: "fitted_mat", "scores", "pattern".

"fitted_mat"

The recovered matrix (after regressing rows on patterns to estimate scores).

"scores"

The estimated scores (estimated by regressing rows on patterns).

"pattern"

The estimated pattern (if none was provided).

Methods

If true_pattern is left NULL then the pattern is estimated via an eigen decomposition on the covariance matrix of mat. The scores are estimated by regressing rows on the pattern provided/estimated. The fitted values are then estimated by multiplying the estimated scores by the provided/estimated patterns.

Examples

# simulate a matrix:

pattern <- t(cbind(c(1,1,1,0,0), c(0,0,0,1,1)))
scores <- matrix(rnorm(10), 5, 2)
mat <- scores %*% pattern

# run PCA:

pca_jg(mat, rank = 2, true_pattern = pattern)

Columbia-PRIME/PCPhelpers documentation built on April 24, 2022, 7:57 p.m.