Learn R Programming

msPCA (version 0.1.0)

fraction_variance_explained: Fraction of variance explained

Description

Computes the fraction of variance explained (variance explained normalized by the trace of the covariance/correlation matrix) by a set of PCs.

Usage

fraction_variance_explained(C, U)

Value

A float.

Arguments

C

A matrix. The correlation or covariance matrix (p x p).

U

A matrix. The matrix containing the r PCs (p x r).

Examples

Run this code
library(datasets)
TestMat <- cor(datasets::mtcars)
mspcares <- mspca(TestMat, 2, c(4,4))
fraction_variance_explained(TestMat, mspcares$x_best)

Run the code above in your browser using DataLab