Skip to contents

Biplots are based on the Singular Value Decomposition, which for a data matrix is $$\mathbf{X} / \sqrt{n} = \mathbf{U} \mathbf{D} \mathbf{V}^T$$ but these are computed and returned in quite different forms by various PCA-like methods. This function provides a common interface, returning the components with standard names.

Usage

get_SVD(pcobj)

Arguments

pcobj

an object returned by prcomp, princomp, PCA, dudi.pca, or lda

Value

A list of four elements

n

The sample size on which the analysis was based

U

Left singular vectors, giving observation scores

D

vector of singular values, the diagonal elements of the matrix \(\mathbf{D}\), which are also the square roots of the eigenvalues of \(\mathbf{X} \mathbf{X}'\)

V

Right singular vectors, giving variable loadings

Examples

data(crime)
crime.pca <- 
  crime |> 
  dplyr::select(where(is.numeric)) |>
  prcomp(scale. = TRUE)

crime.svd <- get_SVD(crime.pca)
#> Error in get_SVD(crime.pca): could not find function "get_SVD"
names(crime.svd)
#> Error in eval(expr, envir, enclos): object 'crime.svd' not found
crime.svd$D
#> Error in eval(expr, envir, enclos): object 'crime.svd' not found