Computes a simple correspondence analysis based on the singular value decomposition.
Usage
ca(object, ...)
# S4 method for data.frame
ca(object, rank = NULL, sup_row = NULL, sup_col = NULL)
# S4 method for matrix
ca(object, rank = NULL, sup_row = NULL, sup_col = NULL)
Arguments
- object
A \(m \times p\) numeric
matrix
or adata.frame
.- ...
Currently not used.
- rank
An
integer
value specifying the maximal number of components to be kept in the results. IfNULL
(the default), \(min(m, p) - 1\) components will be returned.- sup_row
A
numeric
orlogical
vector specifying the indices of the supplementary rows.- sup_col
A
numeric
orlogical
vector specifying the indices of the supplementary columns.
Value
A CA
object.
References
Greenacre, M. J. Theory and Applications of Correspondence Analysis. London: Academic Press, 1984.
Greenacre, M. J. Correspondence Analysis in Practice. Seconde edition. Interdisciplinary Statistics Series. Boca Raton: Chapman & Hall/CRC, 2007.
Lebart, L., Piron, M. and Morineau, A. Statistique exploratoire multidimensionnelle: visualisation et inférence en fouille de données. Paris: Dunod, 2006.
Examples
## Data from Lebart et al. 2006, p. 170-172
data("colours")
## The chi square of independence between the two variables
stats::chisq.test(colours)
#>
#> Pearson's Chi-squared test
#>
#> data: colours
#> X-squared = 138.29, df = 9, p-value < 2.2e-16
#>
## Compute correspondence analysis
X <- ca(colours)
## Get row coordinates
head(get_coordinates(X, margin = 1))
#> F1 F2 F3 .sup
#> marron -0.4921577 -0.08832151 0.021611305 FALSE
#> noisette -0.2125969 0.16739109 -0.100518284 FALSE
#> vert 0.1617534 0.33903957 0.087597437 FALSE
#> bleu 0.5474139 -0.08295428 -0.004709408 FALSE
## Get column coordinates
head(get_coordinates(X, margin = 2))
#> F1 F2 F3 .sup
#> brun -0.5045624 -0.21482046 0.05550909 FALSE
#> chatain -0.1482527 0.03266635 -0.04880414 FALSE
#> roux -0.1295233 0.31964240 0.08315117 FALSE
#> blond 0.8353478 -0.06957934 0.01621471 FALSE
## Get row distances to centroid
head(get_distances(X, margin = 1))
#> marron noisette vert bleu
#> 0.25048691 0.08332116 0.14878530 0.30656555
## Get row inertias
head(get_inertia(X, margin = 1))
#> marron noisette vert bleu
#> 0.09308635 0.01308930 0.01608490 0.11133715
## Get row contributions
head(get_contributions(X, margin = 1))
#> F1 F2 F3
#> marron 43.115744 13.04249 6.6795992
#> noisette 3.400961 19.80398 61.0855951
#> vert 1.354851 55.90952 31.9248234
#> bleu 52.128445 11.24401 0.3099822
## Get eigenvalues
get_eigenvalues(X)
#> eigenvalues variance cumulative
#> F1 0.208772652 89.372732 89.37273
#> F2 0.022226615 9.514911 98.88764
#> F3 0.002598439 1.112356 100.00000