screeplot.msPCA: Scree Plot and Cumulative Explained Variance for msPCA...

View source: R/SRPCAMS_methods.R

screeplot.msPCAR Documentation

Scree Plot and Cumulative Explained Variance for msPCA Objects

Description

Generates a scree plot displaying the explained variance of principal components and a heatmap of cumulative explained variance per group for an object of class msPCA.

Usage

## S3 method for class 'msPCA'
screeplot(x, ...)

Arguments

x

An object of class msPCA.

...

Additional arguments to customize the plot:

text

Logical; whether to display numeric values on the heatmap (default: TRUE).

size

Numeric; text size for labels in the heatmap (default: 5).

cutoff

Numeric; cutoff threshold for explained variance lines and color midpoint, as a proportion (default: 0.8).

gnames

Character vector; optional custom group names (default: N1, N2, ..., Nn).

textrotate

Numeric; rotation angle of text labels on the heatmap (default: 90 degrees).

Value

A list containing two ggplot2 plot objects:

  • A boxplot-based scree plot showing explained variance per principal component across groups.

  • A tile plot showing cumulative explained variance per group and principal component.

Examples

set.seed(236)
data <- matrix(rnorm(1500), ncol = 5)
groups <- sample(1:5, 300, replace = TRUE)
W <- time_weights(N = 5, c(3,2,1))
covs <- ssMRCD(data, groups = groups, weights = W, lambda = 0.3)
pca <- msPCA(eta = 0.3, gamma = 0.7, COVS = covs$MRCDcov)
screeplot(pca, text = TRUE, cutoff = 0.8, size = 4, textrotate = 0)
screeplot(pca, text = FALSE, cutoff = 0.6)


ssMRCD documentation built on Nov. 5, 2025, 7:44 p.m.