get_SVD: Extract the SVD components from a PCA-like object

View source: R/get_SVD.R

get_SVDR Documentation

Extract the SVD components from a PCA-like object

Description

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)
names(crime.svd)
crime.svd$D


ggbiplot documentation built on June 22, 2024, 11:05 a.m.