reflect: Reflect Columns in a Principal Component-like Object

View source: R/reflect.R

reflectR Documentation

Reflect Columns in a Principal Component-like Object

Description

Principle component-like objects have variable loadings (the eigenvectors of the covariance/correlation matrix) whose signs are arbitrary, in the sense that a given column can be reflected (multiplied by -1) without changing the fit.

Usage

reflect(pcobj, columns = 1:2)

Arguments

pcobj

an object returned by prcomp, princomp, PCA, or lda

columns

a vector of indices of the columns to reflect

Details

This function allows one to reflect any columns of the variable loadings (and corresponding observation scores). Coordinates for quantitative supplementary variables are also reflected if present. This is often useful for interpreting a biplot, for example when a component (often the first) has all negative signs.

Value

The pca-like object with specified columns of the variable loadings and observation scores multiplied by -1.

Author(s)

Michael Friendly

See Also

prcomp, princomp, PCA, lda

Examples

data(crime)
crime.pca <- 
  crime |> 
  dplyr::select(where(is.numeric)) |>
  prcomp(scale. = TRUE)
  
 biplot(crime.pca)
 
 crime.pca <- reflect(crime.pca)  # reflect columns 1:2
 biplot(crime.pca)

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