Last updated: 201609. Kajiyama             [ 目次に戻る ]

FactoMineRのCAを利用した2元表(children)の対応分析



CA {FactoMineR}	R Documentation
Correspondence Analysis (CA)

Description

Performs Correspondence Analysis (CA) including supplementary row and/or column points.

Usage

CA(X, ncp = 5, row.sup = NULL, col.sup = NULL, quanti.sup=NULL,
    quali.sup = NULL, graph = TRUE, axes = c(1,2), row.w = NULL)
Arguments

X	a data frame or a table with n rows and p columns, i.e. a contingency table

ncp	number of dimensions kept in the results (by default 5)

row.sup	a vector indicating the indexes of the supplementary rows

col.sup	a vector indicating the indexes of the supplementary columns

quanti.sup	a vector indicating the indexes of the supplementary continuous variables

quali.sup	a vector indicating the indexes of the categorical supplementary variables

graph	boolean, if TRUE a graph is displayed

axes	a length 2 vector specifying the components to plot

row.w	an optional row weights (by default, a vector of 1 and each row has a weight equals to its margin)

Value

Returns a list including:

eig	a matrix containing all the eigenvalues, the percentage of variance and the cumulative percentage of variance

col	a list of matrices with all the results for the column variable (coordinates, square cosine, contributions, inertia)

row	a list of matrices with all the results for the row variable (coordinates, square cosine, contributions, inertia)

col.sup	a list of matrices containing all the results for the supplementary column points (coordinates, square cosine)

row.sup	a list of matrices containing all the results for the supplementary row points (coordinates, square cosine)

quanti.sup	if quanti.sup is not NULL, a matrix containing the results for the supplementary continuous variables 
(coordinates, square cosine)

quali.sup	if quali.sup is not NULL, a list of matrices with all the results for the supplementary categorical 
variables (coordinates of each categories of each variables, v.test which is a criterion with a Normal distribution, 
square correlation ratio)

call	a list with some statistics

Returns the row and column points factor map.The plot may be improved using the argument autolab, 
modifying the size of the labels or selecting some elements thanks to the plot.CA function.

Author(s)

Francois Husson Francois.Husson@agrocampus-ouest.fr,Jeremy Mazet

References

Benzecri, J.-P. (1992) Correspondence Analysis Handbook, New-York : Dekker 
Benzecri, J.-P. (1980) L'analyse des donnees tome 2 : l'analyse des correspondances, Paris : Bordas 
Greenacre, M.J. (1993) Correspondence Analysis in Practice, London : Academic Press
Husson, F., Le, S. and Pages, J. (2009). Analyse de donnees avec R, Presses Universitaires de Rennes.
Husson, F., Le, S. and Pages, J. (2010). Exploratory Multivariate Analysis 
by Example Using R, Chapman and Hall.

See Also

print.CA, summary.CA, ellipseCA, plot.CA, dimdesc,
Video showing how to perform CA with FactoMineR

Examples

data(children)
res.ca <- CA (children, row.sup = 15:18, col.sup = 6:8)
summary(res.ca)
## Ellipses for all the active elements
ellipseCA(res.ca)
## Ellipses around some columns only
ellipseCA(res.ca,ellipse="col",col.col.ell=c(rep("blue",2),rep("transparent",3)),invisible=c("row.sup","col.sup"))


 rm(list=ls(all=TRUE)) # 以前作成したオブジェクトの削除

 library(FactoMineR)
警告メッセージ: 
 パッケージ ‘FactoMineR’ はバージョン 3.1.3 の R の下で造られました 

 ? FactoMineR
CA	Correspondence Analysis (CA)
ellipseCA	Draw confidence ellipses in CA
MCA	Multiple Correspondence Analysis (MCA)
plot.CA	Draw the Correspondence Analysis (CA) graphs
plot.CaGalt	Draw the Correspondence Analysis on Generalised Aggregated Lexical Table (CaGalt) graphs
plot.spMCA	Draw the specific Multiple Correspondence Analysis (spMCA) graphs
print.CA	Print the Correspondance Analysis (CA) results
print.CaGalt	Print the Correspondence Analysis on Generalised Aggregated Lexical Table (CaGalt) results
print.spMCA	Print the specific Multiple Correspondance Analysis (spMCA) results

? children

The data used here is a contingency table that summarizes the answers given by different categories 
of people to the following question : according to you, what are the reasons that can make hesitate 
a woman or a couple to have children?

Format

A data frame with 18 rows and 8 columns. Rows represent the different reasons mentioned, columns 
represent the different categories (education, age) people belong to.

Source

Traitements Statistiques des Enquetes (D. Grange, L.Lebart, eds.) Dunod, 1993


 data(children) # データの読み込み

 children # データ表示
              unqualified cep bepc high_school_diploma university thirty fifty more_fifty
money                  51  64   32                  29         17     59    66         70
future                 53  90   78                  75         22    115   117         86
unemployment           71 111   50                  40         11     79    88        177
circumstances           1   7    5                   5          4      9     8          5
hard                    7  11    4                   3          2      2    17         18
economic                7  13   12                  11         11     18    19         17
egoism                 21  37   14                  26          9     14    34         61
employment             12  35   19                   6          7     21    30         28
finances               10   7    7                   3          1      8    12          8
war                     4   7    7                   6          2      7     6         13
housing                 8  22    7                  10          5     10    27         17
fear                   25  45   38                  38         13     48    59         52
health                 18  27   20                  19          9     13    29         53
work                   35  61   29                  14         12     30    63         58
comfort                 2   4    3                   1          4     NA    NA         NA
disagreement            2   8    2                   5          2     NA    NA         NA
world                   1   5    4                   6          3     NA    NA         NA
to_live                 3   3    1                   3          4     NA    NA         NA


 res.CA <- CA (children, row.sup = 15:18, col.sup = 6:8) # データchildrenを対応分析



 summary(res.CA)

Call:
CA(X = children, row.sup = 15:18, col.sup = 6:8) 

The chi square of independence between the two variables is equal to 98.80159 (p-value =  9.748064e-05 ).

Eigenvalues
                       Dim.1   Dim.2   Dim.3   Dim.4
Variance               0.035   0.013   0.007   0.006
% of var.             57.043  21.132  11.764  10.061
Cumulative % of var.  57.043  78.175  89.939 100.000

Rows (the 10 first)
                      Iner*1000    Dim.1    ctr   cos2    Dim.2    ctr   cos2    Dim.3    ctr   cos2  
money               |     3.759 | -0.115  4.550  0.428 |  0.020  0.371  0.013 |  0.101 16.884  0.328 |
future              |     8.690 |  0.176 17.567  0.716 | -0.098 14.587  0.220 | -0.053  7.568  0.064 |
unemployment        |     9.151 | -0.212 22.616  0.875 | -0.071  6.779  0.097 | -0.004  0.046  0.000 |
circumstances       |     3.804 |  0.401  6.274  0.584 |  0.331 11.544  0.398 | -0.016  0.046  0.001 |
hard                |     1.199 | -0.250  2.994  0.884 |  0.068  0.592  0.065 |  0.060  0.845  0.051 |
economic            |     8.787 |  0.354 12.005  0.484 |  0.321 26.604  0.397 |  0.084  3.280  0.027 |
egoism              |     3.287 |  0.060  0.681  0.073 | -0.026  0.338  0.013 |  0.179 29.496  0.655 |
employment          |     5.648 | -0.137  2.621  0.164 |  0.215 17.555  0.408 | -0.213 30.815  0.398 |
finances            |     3.576 | -0.237  2.790  0.276 | -0.206  5.690  0.209 | -0.044  0.469  0.010 |
war                 |     1.025 |  0.217  2.169  0.749 | -0.075  0.694  0.089 | -0.098  2.139  0.152 |

Columns
                      Iner*1000    Dim.1    ctr   cos2    Dim.2    ctr   cos2    Dim.3    ctr   cos2  
unqualified         |    13.146 | -0.209 25.110  0.676 | -0.081 10.082  0.101 |  0.073 14.659  0.081 |
cep                 |    10.044 | -0.139 18.297  0.645 |  0.056  8.079  0.105 | -0.018  1.520  0.011 |
bepc                |     7.670 |  0.109  6.758  0.312 | -0.028  1.251  0.021 | -0.147 59.874  0.570 |
high_school_diploma |    17.732 |  0.274 37.976  0.758 | -0.121 20.099  0.149 |  0.077 14.407  0.059 |
university          |    13.468 |  0.231 11.859  0.312 |  0.318 60.488  0.589 |  0.094  9.540  0.052 |

Supplementary rows
                      Dim.1  cos2   Dim.2  cos2   Dim.3  cos2  
comfort             | 0.210 0.069 | 0.703 0.775 | 0.071 0.008 |
disagreement        | 0.146 0.131 | 0.119 0.087 | 0.171 0.180 |
world               | 0.523 0.876 | 0.143 0.065 | 0.084 0.023 |
to_live             | 0.308 0.139 | 0.502 0.369 | 0.521 0.397 |

Supplementary columns
                       Dim.1   cos2    Dim.2   cos2    Dim.3   cos2  
thirty              |  0.105  0.138 | -0.060  0.044 | -0.103  0.132 |
fifty               | -0.017  0.011 |  0.049  0.090 | -0.016  0.009 |
more_fifty          | -0.177  0.286 | -0.048  0.021 |  0.101  0.093 |

 ellipseCA(res.CA) # 楕円を描く



 ellipseCA(res.CA,ellipse="col",col.col.ell=c(rep("blue",2),rep("transparent",3)),
 invisible=c("row.sup","col.sup")) # 楕円を描く





  FactoMineRのCAを利用した2元表(children)の対応分析  [ 目次に戻る ]