Learn Data & AI Skills | 50% off
Get 50% off unlimited learning

nexus (version 0.6.0)

pca: Principal Components Analysis

Description

Computes a principal components analysis based on the singular value decomposition.

Usage

# S4 method for CompositionMatrix
pca(
  object,
  center = TRUE,
  scale = FALSE,
  rank = NULL,
  sup_row = NULL,
  sup_col = NULL,
  weight_row = NULL,
  weight_col = NULL
)

# S4 method for LogRatio pca( object, center = TRUE, scale = FALSE, rank = NULL, sup_row = NULL, sup_col = NULL, weight_row = NULL, weight_col = NULL )

Value

A dimensio::PCA object. See dimensio::pca() for details.

Arguments

object

A CompositionMatrix or LogRatio object.

center

A logical scalar: should the variables be shifted to be zero centered?

scale

A logical scalar: should the variables be scaled to unit variance?

rank

An integer value specifying the maximal number of components to be kept in the results. If NULL (the default), p1 components will be returned.

sup_row

A vector specifying the indices of the supplementary rows.

sup_col

A vector specifying the indices of the supplementary columns.

weight_row

A numeric vector specifying the active row (individual) weights. If NULL (the default), uniform weights are used. Row weights are internally normalized to sum 1

weight_col

A numeric vector specifying the active column (variable) weights. If NULL (the default), uniform weights (1) are used.

Methods (by class)

  • pca(CompositionMatrix): PCA of centered log-ratio, i.e. log-ratio analysis (LRA).

Author

N. Frerebeau

References

Aitchison, J. and Greenacre, M. (2002). Biplots of compositional data. Journal of the Royal Statistical Society: Series C (Applied Statistics), 51: 375-392. tools:::Rd_expr_doi("10.1111/1467-9876.00275").

Filzmoser, P., Hron, K. and Reimann, C. (2009). Principal component analysis for compositional data with outliers. Environmetrics, 20: 621-632. tools:::Rd_expr_doi("10.1002/env.966").

See Also

dimensio::pca(), dimensio::biplot(), dimensio::screeplot(), dimensio::viz_individuals(), dimensio::viz_variables()

Examples

Run this code
## Data from Day et al. 2011
data("kommos", package = "folio") # Coerce to compositional data
kommos <- remove_NA(kommos, margin = 1) # Remove cases with missing values
coda <- as_composition(kommos, groups = 1) # Use ceramic types for grouping

## Log-Ratio Analysis
X <- pca(coda)

## Biplot
biplot(X)

## Explore results
viz_individuals(X, extra_quali = group_names(coda))
viz_variables(X)

Run the code above in your browser using DataLab