Skip to contents

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

Value

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

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.

See also

Author

Michael Friendly

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)