explained_var: Explained Variance summarized over Groups

View source: R/sparsePCA_helpers.R

explained_varR Documentation

Explained Variance summarized over Groups

Description

Explained Variance summarized over Groups

Usage

explained_var(COVS, PC, k, type = "scaled", cor = FALSE, gamma = 0.5)

Arguments

COVS

list of covariance matrices

PC

matrix-like object holding the loadings of length np

k

which component should be evaluated

type

character, either "scaled" for scaling using the extremes solutions or "percent" as percentage of overall variance.

cor

logical, if COVS is a correlation matrix or not

gamma

scalar between 0 and 1 indicatig distribution of sparsity.

Value

Returns scalar

Examples

S1 = matrix(c(1, 0.9, 0.8, 0.5,
              0.9, 1.1, 0.7, 0.4,
              0.8, 0.7, 1.5, 0.2,
              0.5, 0.4, 0.2, 1), ncol = 4)
S2 = t(S1)%*% S1
S2 = S2/2

explained_var(COVS = list(S1, S2),
              PC = c(1,0,0,0,sqrt(2),0,0,-sqrt(2)),
              k = 1,
              cor = FALSE,
              gamma = 0.5)

explained_var(COVS = list(cov2cor(S1), cov2cor(S2)),
              PC = c(1,0,0,0,sqrt(2),0,0,-sqrt(2)),
              k = 1,
              cor = TRUE,
              gamma = 0.5)

ssMRCD documentation built on Sept. 11, 2024, 5:14 p.m.