screeplot.princomp.BData: Screeplot for PCA of Distributional Data

View source: R/PCA.R

screeplot.princomp.BDataR Documentation

Screeplot for PCA of Distributional Data

Description

Creates a screeplot showing the variance (or eigenvalue) associated with each principal component. This is a standard tool for deciding how many principal components to retain based on the "elbow" criterion.

Usage

## S3 method for class 'princomp.BData'
screeplot(
  x,
  npcs = min(10, length(x$sdev)),
  type = c("barplot", "lines"),
  main = "Screeplot",
  ...
)

Arguments

x

A 'princomp.BData' object.

npcs

Number of principal components to include in the plot. Default is 'min(10, length(x$sdev))'.

type

Character string specifying the plot type:

'"barplot"'

Bar chart of variances (default).

'"lines"'

Line plot connecting variance values.

main

Plot title. Default is '"Screeplot"'.

...

Additional graphical parameters.

Details

The screeplot displays the eigenvalues (variances) of the principal components in decreasing order. The name comes from the plot's resemblance to a scree slope at the base of a mountain.

## How to Use

Look for an "elbow" in the plot where the variance drops off sharply. Components before the elbow are typically considered important and retained, while those after the elbow contribute little to the overall structure.

Alternative criteria for choosing components include:

  • Retain components explaining a target percentage of variance (see 'plot(x, type="variance")').

  • Kaiser criterion: retain components with variance > 1 (when using correlation matrix, 'cor=TRUE').

Value

Invisibly returns the variance values for each component.

Author(s)

Matthias Templ

See Also

princomp.BData for the PCA analysis.

plot.princomp.BData for additional plot types including cumulative variance plots.

Other PCA: biplot.princomp.BData(), plot.princomp.BData(), plot.princomp.BData.grouped(), plot.princomp.BData.multivariate(), predict.princomp.BData(), princomp.BData(), summary.princomp.BData()

Examples

meanDist <- BDataPDFs(list(dunif), basis = B2Unif01Basis7)
gaussProc <- B2GaussianDistribution(meanDist, function(x,y) exp(-4*abs(x-y)^1.7))
pcaResult <- princomp(as.BDataSplines(simulate(gaussProc, 25, seed = 42)))

# Standard barplot screeplot
screeplot(pcaResult)

# Line plot version
screeplot(pcaResult, type = "lines")


DistributionalDDA documentation built on Oct. 20, 2026, 5:06 p.m.