biplot.princomp.BData: Biplot for PCA of Distributional Data

View source: R/PCA.R

biplot.princomp.BDataR Documentation

Biplot for PCA of Distributional Data

Description

Creates a biplot that simultaneously displays the principal component scores (observations) and loadings (variables/coefficients) in the same plot. This visualization helps understand relationships between observations and the underlying coefficient structure.

Usage

## S3 method for class 'princomp.BData'
biplot(
  x,
  choices = 1:2,
  scale = 0,
  pc.biplot = FALSE,
  main = NULL,
  col = c("black", "red"),
  cex = c(0.8, 0.8),
  xlabs = NULL,
  ylabs = NULL,
  expand = 1,
  arrow.len = 0.1,
  ...
)

Arguments

x

An object of class 'princomp.BData' as returned by princomp.BData.

choices

Integer vector of length 2 specifying which principal components to display. Default is 'c(1, 2)' for the first two components.

scale

Numeric scaling factor controlling the relative scaling of scores and loadings:

'0'

(Default) Distance biplot: Loadings unscaled, scores scaled. Distances between observation labels approximate Euclidean distances in the full space. Best for seeing relationships between observations.

'1'

Correlation biplot: Loadings scaled by standard deviations. Inner products between loading arrows approximate covariances. Best for seeing relationships between variables.

pc.biplot

Logical. If ‘TRUE', use Gabriel’s (1971) biplot scaling, which sets 'scale=1'. Default is 'FALSE'.

main

Character string for plot title. Default is '"Biplot"'.

col

Vector of two colors: first for observation labels, second for loading arrows. Default is 'c("black", "red")'.

cex

Vector of two character expansion factors: first for observation labels, second for loading labels. Default is 'c(0.8, 0.8)'.

xlabs

Character vector of labels for observations. Default uses observation numbers (1, 2, 3, ...).

ylabs

Character vector of labels for loading arrows (coefficients). Default uses '"C1"', '"C2"', etc.

expand

Numeric expansion factor for loading arrows. Increase this if the arrows are too short to see clearly. Default is 1.

arrow.len

Length of arrow heads. Default is 0.1.

...

Additional graphical parameters passed to the underlying plot.

Details

## Biplot Interpretation

In a biplot:

  • Observations (numbers/text) represent individual distributions. Observations close together have similar distribution shapes.

  • Loading arrows (red arrows labeled C1, C2, etc.) represent spline basis coefficients. The direction and length indicate how each coefficient contributes to the principal components.

  • Projecting an observation onto a loading arrow approximates that observation's value on that coefficient (relative to the mean).

  • Arrow angles: Arrows pointing in similar directions indicate positively correlated coefficients; opposite directions indicate negative correlation; perpendicular arrows indicate uncorrelated coefficients.

## Note on Coefficient Interpretation

Unlike PCA on raw data where variables have direct meaning, the "variables" here are spline basis coefficients. These are abstract and their individual interpretation may not be intuitive. For understanding how distributions vary, the plot.princomp.BData function with 'type="eigenfunctions"' provides a more interpretable visualization showing how distribution shapes change along each PC direction.

## Why Biplot Works for ZB-Splines

The biplot is meaningful for the default ZB-spline basis because ZB-splines have **local support**: each basis function is non-zero only in a specific region of the domain. This means coefficient i primarily reflects the behavior of the distribution near knot region i. When a loading arrow for coefficient Ci points strongly in a PC direction, it indicates that variation in that region of the domain is associated with that principal component.

**Important:** If orthonormal splines were used instead, the biplot would lose this interpretability because orthonormal basis functions have global support (they are non-zero across the entire domain), so each coefficient would mix information from everywhere rather than representing a local region.

Value

Invisibly returns a list containing the scaled 'scores' and 'loadings' matrices as plotted.

Author(s)

Matthias Templ

References

Gabriel, K. R. (1971). The biplot graphic display of matrices with application to principal component analysis. Biometrika, 58(3), 453-467.

See Also

princomp.BData for performing the PCA.

plot.princomp.BData for other visualization options, especially 'type="loadings"' for functional interpretation.

biplot for the generic biplot function.

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

Examples

## Create example PCA result
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)))

## Basic biplot
biplot(pcaResult)

## Biplot of PC2 vs PC3
biplot(pcaResult, choices = c(2, 3))

## Correlation biplot (scale=1)
biplot(pcaResult, scale = 1)

## Customized biplot
biplot(pcaResult,
       col = c("blue", "darkgreen"),
       cex = c(1, 0.7),
       expand = 1.5,
       main = "PCA Biplot of Distributional Data")


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