methods-cancor {ordr}R Documentation

Functionality for canonical correlations

Description

These methods extract data from, and attribute new data to, objects of class "cancor_ord". This is a class introduced in this package to identify objects returned by cancor_ord(), which wraps stats::cancor().

Usage

## S3 method for class 'cancor_ord'
as_tbl_ord(x)

## S3 method for class 'cancor_ord'
recover_rows(x)

## S3 method for class 'cancor_ord'
recover_cols(x)

## S3 method for class 'cancor_ord'
recover_inertia(x)

## S3 method for class 'cancor_ord'
recover_coord(x)

## S3 method for class 'cancor_ord'
recover_conference(x)

## S3 method for class 'cancor_ord'
recover_supp_rows(x)

## S3 method for class 'cancor_ord'
recover_supp_cols(x)

## S3 method for class 'cancor_ord'
recover_aug_rows(x)

## S3 method for class 'cancor_ord'
recover_aug_cols(x)

## S3 method for class 'cancor_ord'
recover_aug_coord(x)

Arguments

x

An ordination object.

Details

The canonical coefficients (loadings) are obtained directly from the underlying singular value decomposition and constitute the active elements. If canonical scores are returned, then they and the structure correlations are made available as supplementary elements. ordr takes rows and columns from the intraset correlations ⁠$xstructure⁠ and ⁠$ystructure⁠, on which no intertia is conferred; the interset correlations can be obtained by conferring inertia onto these.

A biplot of the canonical coefficients can be interpreted as approximating the X-Y inner product matrix, inversely weighted by the X and Y variances. The canonical scores and structure coefficients are available as supplementary points if returned by cancor_ord(). These can be used to create biplots of the case scores as linear combinations of loadings (the coefficients, in standard coordinates, overlaid with the scores) or of intraset and interset correlations with respect to either data set (the correlations with inertia conferred entirely onto rows or onto columns). Greenacre (1984) and ter Braak (1990) describe these families, though ter Braak recommends against the first.

Value

The recovery generics ⁠recover_*()⁠ return core model components, distribution of inertia, supplementary elements, and intrinsic metadata; but they require methods for each model class to tell them what these components are.

The generic as_tbl_ord() returns its input wrapped in the 'tbl_ord' class. Its methods determine what model classes it is allowed to wrap. It then provides 'tbl_ord' methods with access to the recoverers and hence to the model components.

References

Greenacre MJ (1984) Theory and applications of correspondence analysis. London: Academic Press, ISBN 0-12-299050-1. http://www.carme-n.org/?sec=books5

ter Braak CJF (1990) "Interpreting canonical correlation analysis through biplots of structure correlations and weights". Psychometrika 55(3), 519–531. doi:10.1007/BF02294765

See Also

Other methods for singular value decomposition-based techniques: methods-correspondence, methods-lda, methods-lra, methods-mca, methods-prcomp, methods-princomp, methods-svd

Other models from the stats package: methods-cmds, methods-factanal, methods-kmeans, methods-lm, methods-prcomp, methods-princomp

Examples

# data frame of life-cycle savings across countries
class(LifeCycleSavings)
head(LifeCycleSavings)
savings_pop <- LifeCycleSavings[, c("pop15", "pop75")]
savings_oec <- LifeCycleSavings[, c("sr", "dpi", "ddpi")]

# canonical correlation analysis with scores and correlations included
savings_cca <- cancor_ord(savings_pop, savings_oec, scores = TRUE)
savings_cca <- augment_ord(as_tbl_ord(savings_cca))
head(get_cols(savings_cca))
head(get_cols(savings_cca, elements = "score"))
get_rows(savings_cca, elements = "structure")
get_cols(savings_cca, elements = "structure")

# biplot of interset and intraset correlations with the population data
savings_cca %>%
  confer_inertia("cols") %>%
  ggbiplot(aes(label = name, color = .matrix)) +
  theme_bw() + theme_biplot() +
  geom_unit_circle() +
  geom_rows_vector(arrow = NULL, elements = "structure") +
  geom_cols_vector(arrow = NULL, elements = "structure", linetype = "dashed") +
  geom_rows_text(elements = "structure", hjust = "outward") +
  geom_cols_text(elements = "structure", hjust = "outward") +
  scale_color_brewer(limits = c("rows", "cols"), type = "qual") +
  expand_limits(x = c(-1, 1), y = c(-1, 1))

# biplot with scores as supplemental elements
savings_cca %>%
  confer_inertia("rows") %>%
  ggbiplot(aes(label = name), sec.axes = "cols", scale.factor = 5L) +
  theme_biplot() +
  geom_cols_vector(elements = "active") +
  geom_cols_text_radiate(elements = "active") +
  geom_rows_text(elements = "score", subset = seq(50L))

[Package ordr version 0.1.1 Index]