Find the principal canonical correlation and corresponding row- and
column-scores from a correspondence analysis of a two-way contingency
table.
Usage
corresp(x, ...)
## S3 method for class 'matrix'
corresp(x, nf = 1, ...)
## S3 method for class 'factor'
corresp(x, y, ...)
## S3 method for class 'data.frame'
corresp(x, ...)
## S3 method for class 'xtabs'
corresp(x, ...)
## S3 method for class 'formula'
corresp(formula, data, ...)
Arguments
x, formula
The function is generic, accepting various forms of the principal
argument for specifying a two-way frequency table. Currently accepted
forms are matrices, data frames (coerced to frequency tables), objects
of class "xtabs" and formulae of the form ~ F1 + F2,
where F1 and F2 are factors.
nf
The number of factors to be computed. Note that although 1 is the most
usual, one school of thought takes the first two singular vectors for
a sort of biplot.
y
a second factor for a cross-classification.
data
a data frame against which to preferentially resolve
variables in the formula.
...
If the principal argument is a formula, a data frame may be specified
as well from which variables in the formula are preferentially
satisfied.
Details
See Venables & Ripley (2002). The plot method produces a graphical
representation of the table if nf=1, with the areas of circles
representing the numbers of points. If nf is two or more the
biplot method is called, which plots the second and third columns of
the matrices A = Dr^(-1/2) U L and B = Dc^(-1/2) V L where the
singular value decomposition is U L V. Thus the x-axis is the
canonical correlation times the row and column scores. Although this
is called a biplot, it does not have any useful inner product
relationship between the row and column scores. Think of this as an
equally-scaled plot with two unrelated sets of labels. The origin is
marked on the plot with a cross. (For other versions of this plot see
the book.)
Value
An list object of class "correspondence" for which
print, plot and biplot methods are supplied.
The main components are the canonical correlation(s) and the row
and column scores.
References
Venables, W. N. and Ripley, B. D. (2002)
Modern Applied Statistics with S. Fourth edition. Springer.
Gower, J. C. and Hand, D. J. (1996)
Biplots. Chapman & Hall.
See Also
svd, princomp.
Examples
(ct <- corresp(~ Age + Eth, data = quine))
plot(ct)
corresp(caith)
biplot(corresp(caith, nf = 2))
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(MASS)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MASS/corresp.Rd_%03d_medium.png", width=480, height=480)
> ### Name: corresp
> ### Title: Simple Correspondence Analysis
> ### Aliases: corresp corresp.xtabs corresp.data.frame corresp.default
> ### corresp.factor corresp.formula corresp.matrix
> ### Keywords: category multivariate
>
> ### ** Examples
>
> (ct <- corresp(~ Age + Eth, data = quine))
First canonical correlation(s): 0.05317534
Age scores:
F0 F1 F2 F3
-0.3344445 1.4246090 -1.0320002 -0.4612728
Eth scores:
A N
-1.0563816 0.9466276
> plot(ct)
>
> corresp(caith)
First canonical correlation(s): 0.4463684
Row scores:
blue light medium dark
-0.89679252 -0.98731818 0.07530627 1.57434710
Column scores:
fair red medium dark black
-1.21871379 -0.52257500 -0.09414671 1.31888486 2.45176017
> biplot(corresp(caith, nf = 2))
>
>
>
>
>
> dev.off()
null device
1
>