Learn R Programming

weird (version 3.1.0)

augment.Pca: Augment data with results from a robust principal component analysis

Description

Augment the data with information from an rrcov::Pca* object (such as the output of rrcov::PcaHubert() or rrcov::PcaClassic()). The returned tibble contains the principal component scores (.fittedPC1, .fittedPC2, ...), the score distance (.sd) and the orthogonal distance (.od) of each observation. The score distance measures how far an observation lies from the centre within the projection subspace, while the orthogonal distance measures how far it lies from the subspace. If data is supplied, its columns are returned alongside these results.

Usage

# S3 method for Pca
augment(x, data = NULL, ...)

Value

A tibble::tibble() with one row per observation.

Arguments

x

An rrcov::Pca* object.

data

The original data matrix or data frame used to compute the PCA. If supplied, its columns are bound to the left of the returned tibble.

...

Unused.

Author

Rob J Hyndman

Examples

Run this code
if (FALSE) { # requireNamespace("rrcov", quietly = TRUE)
Y <- oldfaithful[, c("duration", "waiting")]
pca <- rrcov::PcaHubert(as.matrix(Y), k = 1)
broom::augment(pca, data = Y)
}

Run the code above in your browser using DataLab