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

パッケージFactoMineRのMCAを利用した多元表(tea)の多重対応分析



MCA {FactoMineR}	R Documentation  Multiple Correspondence Analysis (MCA)

Description

Performs Multiple Correspondence Analysis (MCA) with supplementary individuals, supplementary quantitative 
variables and supplementary categorical variables.Missing values are treated as an additional level, 
categories which are rare can be ventilated

Usage

MCA(X, ncp = 5, ind.sup = NULL, quanti.sup = NULL, 
    quali.sup = NULL, graph = TRUE, level.ventil = 0, 
    axes = c(1,2), row.w = NULL, method="Indicator",
    na.method="NA", tab.disj=NULL)
Arguments

X	a data frame with n rows (individuals) and p columns (categorical variables)

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

ind.sup	a vector indicating the indexes of the supplementary individuals

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

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

graph	boolean, if TRUE a graph is displayed

level.ventil	a proportion corresponding to the level under which the category is ventilated; 
by default, 0 and no ventilation is done

axes	a length 2 vector specifying the components to plot

row.w	an optional row weights (by default, a vector of 1 for uniform row weights)

method	a string corresponding to the name of the method used: "Indicator" (by default) is the CA on the Indicator matrix, 
"Burt" is the CA on the Burt table. For Burt and the Indicator, the graph of the individuals and the graph of 
the categories are given

na.method	a string corresponding to the name of the method used if there are missing values; available methods are 
"NA" or "Average" (by default, "NA")

tab.disj	optional data.frame corresponding to the disjunctive table used for the analysis;it corresponds to 
a disjunctive table obtained from imputation method (see package missMDA).

Value

Returns a list including:

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

var	a list of matrices containing all the results for the active variables (coordinates, square cosine, 
contributions, v.test, square correlation ratio)

ind	a list of matrices containing all the results for the active individuals (coordinates, square cosine, contributions)

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

quanti.sup	a matrix containing the coordinates of the supplementary quantitative variables (the correlation between 
a variable and an axis is equal to the variable coordinate on the axis)

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

call	a list with some statistics

Returns the graphs of the individuals and categories and the graph with the variables.The plots may be improved using 
the argument autolab, modifying the size of the labels or selecting some elements thanks to the plot.MCA function.

Author(s)

Francois Husson husson@agrocampus-ouest.fr, Julie Josse, Jeremy Mazet

References

Husson, F., Le, S. and Pages, J. (2010). Exploratory Multivariate Analysis by Example Using R, 
Chapman and Hall.

See Also

plotellipses, summary.MCA,print.MCA, plot.MCA, dimdesc,
Video showing how to perform MCA with FactoMineR

Examples

## Tea example
 data(tea)
 res.mca <- MCA(tea,quanti.sup=19,quali.sup=20:36)
 summary(res.mca)
 plot(res.mca,invisible=c("var","quali.sup","quanti.sup"),cex=0.7)
 plot(res.mca,invisible=c("ind","quali.sup","quanti.sup"),cex=0.8)
 plot(res.mca,invisible=c("quali.sup","quanti.sup"),cex=0.8)
 dimdesc(res.mca)
 plotellipses(res.mca,keepvar=1:4)
 plotellipses(res.mca,keepvar="Tea")


 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

 data(tea) # スタック形式のデータteaの読み込み   36変数300サンプル
 ? tea
A data frame with 300 rows and 36 columns. Rows represent the individuals, columns represent 
the different questions. The first 18 questions are active ones, the 19th is a supplementary 
quantitative variable (the age) and the last variables are supplementary categorical variables

 str(tea) #> スタック形式のデータ 36変数300サンプル
'data.frame':   300 obs. of  36 variables:
 $ breakfast       : Factor w/ 2 levels "breakfast","Not.breakfast": 1 1 2 2 1 2 1 2 1 1 ...
 $ tea.time        : Factor w/ 2 levels "Not.tea time",..: 1 1 2 1 1 1 2 2 2 1 ...
 $ evening         : Factor w/ 2 levels "evening","Not.evening": 2 2 1 2 1 2 2 1 2 1 ...
 $ lunch           : Factor w/ 2 levels "lunch","Not.lunch": 2 2 2 2 2 2 2 2 2 2 ...
 $ dinner          : Factor w/ 2 levels "dinner","Not.dinner": 2 2 1 1 2 1 2 2 2 2 ...
 $ always          : Factor w/ 2 levels "always","Not.always": 2 2 2 2 1 2 2 2 2 2 ...
 $ home            : Factor w/ 2 levels "home","Not.home": 1 1 1 1 1 1 1 1 1 1 ...
 $ work            : Factor w/ 2 levels "Not.work","work": 1 1 2 1 1 1 1 1 1 1 ...
 $ tearoom         : Factor w/ 2 levels "Not.tearoom",..: 1 1 1 1 1 1 1 1 1 2 ...
 $ friends         : Factor w/ 2 levels "friends","Not.friends": 2 2 1 2 2 2 1 2 2 2 ...
 $ resto           : Factor w/ 2 levels "Not.resto","resto": 1 1 2 1 1 1 1 1 1 1 ...
 $ pub             : Factor w/ 2 levels "Not.pub","pub": 1 1 1 1 1 1 1 1 1 1 ...
 $ Tea             : Factor w/ 3 levels "black","Earl Grey",..: 1 1 2 2 2 2 2 1 2 1 ...
 $ How             : Factor w/ 4 levels "alone","lemon",..: 1 3 1 1 1 1 1 3 3 1 ...
 $ sugar           : Factor w/ 2 levels "No.sugar","sugar": 2 1 1 2 1 1 1 1 1 1 ...
 $ how             : Factor w/ 3 levels "tea bag","tea bag+unpackaged",..: 1 1 1 1 1 1 1 1 2 2 ...
 $ where           : Factor w/ 3 levels "chain store",..: 1 1 1 1 1 1 1 1 2 2 ...
 $ price           : Factor w/ 6 levels "p_branded","p_cheap",..: 4 6 6 6 6 3 6 6 5 5 ...
 $ age             : int  39 45 47 23 48 21 37 36 40 37 ...
 $ sex             : Factor w/ 2 levels "F","M": 2 1 1 2 2 2 2 1 2 2 ...
 $ SPC             : Factor w/ 7 levels "employee","middle",..: 2 2 4 6 1 6 5 2 5 5 ...
 $ Sport           : Factor w/ 2 levels "Not.sportsman",..: 2 2 2 1 2 2 2 2 2 1 ...
 $ age_Q           : Factor w/ 5 levels "15-24","25-34",..: 3 4 4 1 4 1 3 3 3 3 ...
 $ frequency       : Factor w/ 4 levels "1/day","1 to 2/week",..: 1 1 3 1 3 1 4 2 3 3 ...
 $ escape.exoticism: Factor w/ 2 levels "escape-exoticism",..: 2 1 2 1 1 2 2 2 2 2 ...
 $ spirituality    : Factor w/ 2 levels "Not.spirituality",..: 1 1 1 2 2 1 1 1 1 1 ...
 $ healthy         : Factor w/ 2 levels "healthy","Not.healthy": 1 1 1 1 2 1 1 1 2 1 ...
 $ diuretic        : Factor w/ 2 levels "diuretic","Not.diuretic": 2 1 1 2 1 2 2 2 2 1 ...
 $ friendliness    : Factor w/ 2 levels "friendliness",..: 2 2 1 2 1 2 2 1 2 1 ...
 $ iron.absorption : Factor w/ 2 levels "iron absorption",..: 2 2 2 2 2 2 2 2 2 2 ...
 $ feminine        : Factor w/ 2 levels "feminine","Not.feminine": 2 2 2 2 2 2 2 1 2 2 ...
 $ sophisticated   : Factor w/ 2 levels "Not.sophisticated",..: 1 1 1 2 1 1 1 2 2 1 ...
 $ slimming        : Factor w/ 2 levels "No.slimming",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ exciting        : Factor w/ 2 levels "exciting","No.exciting": 2 1 2 2 2 2 2 2 2 2 ...
 $ relaxing        : Factor w/ 2 levels "No.relaxing",..: 1 1 2 2 2 2 2 2 2 2 ...
 $ effect.on.health: Factor w/ 2 levels "effect on health",..: 2 2 2 2 2 2 2 2 2 2 ...

 res.mca <- MCA(tea,quanti.sup=19,quali.sup=20:36) # データteaを対応分析


図1-1


図1-2

図1-3

図1-4

図1-5
summary(res.mca) Call: MCA(X = tea, quanti.sup = 19, quali.sup = 20:36) Eigenvalues Dim.1 Dim.2 Dim.3 Dim.4 Dim.5 Dim.6 Dim.7 Dim.8 Dim.9 Dim.10 Dim.11 Dim.12 Dim.13 Dim.14 Dim.15 Dim.16 Variance 0.148 0.122 0.090 0.078 0.074 0.071 0.068 0.065 0.062 0.059 0.057 0.054 0.052 0.049 0.048 0.047 % of var. 9.885 8.103 6.001 5.204 4.917 4.759 4.522 4.355 4.123 3.902 3.805 3.628 3.462 3.250 3.221 3.127 Cumulative % of var. 9.885 17.988 23.989 29.192 34.109 38.868 43.390 47.745 51.867 55.769 59.574 63.202 66.664 69.914 73.135 76.262 Dim.17 Dim.18 Dim.19 Dim.20 Dim.21 Dim.22 Dim.23 Dim.24 Dim.25 Dim.26 Dim.27 Variance 0.046 0.040 0.038 0.037 0.036 0.035 0.031 0.029 0.027 0.021 0.017 % of var. 3.037 2.683 2.541 2.438 2.378 2.323 2.055 1.915 1.821 1.407 1.139 Cumulative % of var. 79.298 81.982 84.523 86.961 89.339 91.662 93.717 95.633 97.454 98.861 100.000 Individuals (the 10 first) Dim.1 ctr cos2 Dim.2 ctr cos2 Dim.3 ctr cos2 1 | -0.541 0.658 0.143 | -0.149 0.061 0.011 | -0.306 0.347 0.046 | 2 | -0.361 0.293 0.133 | -0.078 0.017 0.006 | -0.633 1.483 0.409 | 3 | 0.073 0.012 0.003 | -0.169 0.079 0.018 | 0.246 0.224 0.038 | 4 | -0.572 0.735 0.235 | 0.018 0.001 0.000 | 0.203 0.153 0.030 | 5 | -0.253 0.144 0.079 | -0.118 0.038 0.017 | 0.006 0.000 0.000 | 6 | -0.684 1.053 0.231 | 0.032 0.003 0.001 | -0.018 0.001 0.000 | 7 | -0.111 0.027 0.022 | -0.182 0.090 0.059 | -0.207 0.159 0.077 | 8 | -0.210 0.099 0.043 | -0.068 0.013 0.004 | -0.421 0.655 0.174 | 9 | 0.118 0.031 0.012 | 0.229 0.144 0.044 | -0.538 1.070 0.244 | 10 | 0.258 0.150 0.045 | 0.478 0.627 0.156 | -0.482 0.861 0.158 | Categories (the 10 first) Categorical variables (eta2) Dim.1 ctr cos2 v.test Dim.2 ctr cos2 v.test Dim.3 ctr cos2 v.test Dim.1 Dim.2 Dim.3 breakfast | 0.166 0.495 0.025 2.756 | -0.166 0.607 0.026 -2.764 | -0.483 6.900 0.215 -8.017 | breakfast | 0.025 0.026 0.215 | Not.breakfast | -0.153 0.457 0.025 -2.756 | 0.154 0.560 0.026 2.764 | 0.445 6.369 0.215 8.017 | tea.time | 0.192 0.007 0.054 | Not.tea time | -0.498 4.053 0.192 -7.578 | 0.093 0.174 0.007 1.423 | 0.265 1.886 0.054 4.027 | evening | 0.053 0.002 0.106 | tea time | 0.386 3.142 0.192 7.578 | -0.072 0.135 0.007 -1.423 | -0.205 1.462 0.054 -4.027 | lunch | 0.075 0.026 0.016 | evening | 0.319 1.307 0.053 3.985 | -0.058 0.053 0.002 -0.728 | 0.451 4.312 0.106 5.640 | dinner | 0.033 0.048 0.022 | Not.evening | -0.167 0.683 0.053 -3.985 | 0.030 0.028 0.002 0.728 | -0.236 2.254 0.106 -5.640 | always | 0.045 0.001 0.101 | lunch | 0.659 2.385 0.075 4.722 | -0.390 1.018 0.026 -2.793 | 0.301 0.822 0.016 2.160 | home | 0.005 0.000 0.134 | Not.lunch | -0.113 0.410 0.075 -4.722 | 0.067 0.175 0.026 2.793 | -0.052 0.141 0.016 -2.160 | work | 0.112 0.043 0.005 | dinner | -0.661 1.146 0.033 -3.136 | 0.796 2.025 0.048 3.774 | 0.535 1.235 0.022 2.537 | tearoom | 0.372 0.022 0.008 | Not.dinner | 0.050 0.086 0.033 3.136 | -0.060 0.152 0.048 -3.774 | -0.040 0.093 0.022 -2.537 | friends | 0.243 0.015 0.103 | Supplementary categories (the 10 first) Supplementary categorical variables (eta2) Dim.1 cos2 v.test Dim.2 cos2 v.test Dim.3 cos2 v.test Dim.1 Dim.2 Dim.3 F | 0.151 0.033 3.158 | -0.109 0.017 -2.278 | -0.048 0.003 -0.998 | sex | 0.033 0.017 0.003 | M | -0.221 0.033 -3.158 | 0.159 0.017 2.278 | 0.070 0.003 0.998 | SPC | 0.032 0.053 0.076 | employee | -0.153 0.006 -1.313 | -0.151 0.006 -1.289 | 0.103 0.003 0.884 | Sport | 0.001 0.000 0.002 | middle | -0.030 0.000 -0.205 | 0.336 0.017 2.281 | -0.284 0.012 -1.928 | age_Q | 0.008 0.077 0.146 | non-worker | -0.036 0.000 -0.324 | 0.185 0.009 1.666 | -0.291 0.023 -2.620 | frequency | 0.094 0.006 0.064 | other worker | 0.040 0.000 0.187 | 0.013 0.000 0.061 | -0.063 0.000 -0.289 | escape.exoticism | 0.000 0.007 0.000 | senior | 0.415 0.023 2.608 | 0.072 0.001 0.452 | -0.187 0.005 -1.177 | spirituality | 0.005 0.000 0.016 | student | 0.032 0.000 0.305 | -0.317 0.031 -3.022 | 0.394 0.047 3.760 | healthy | 0.000 0.000 0.008 | workman | -0.417 0.007 -1.473 | 0.249 0.003 0.878 | 0.343 0.005 1.209 | diuretic | 0.004 0.000 0.013 | Not.sportsman | -0.030 0.001 -0.426 | 0.018 0.000 0.260 | -0.051 0.002 -0.721 | friendliness | 0.071 0.001 0.013 | Supplementary continuous variable Dim.1 Dim.2 Dim.3 age | 0.042 | 0.204 | -0.340 | plot(res.mca,invisible=c("var","quali.sup","quanti.sup"),cex=0.7) #2-1 plot(res.mca,invisible=c("ind","quali.sup","quanti.sup"),cex=0.8) #3-1
  #2-1

  #3-1

plot(res.mca,invisible=c("quali.sup","quanti.sup"),cex=0.8) #4-1
  #4-1


dimdesc(res.mca) #5-1
$`Dim 1`
$`Dim 1`$quali
                     R2      p.value
where        0.41793014 1.255462e-35
tearoom      0.37189109 6.082138e-32
how          0.29882863 1.273180e-23
friends      0.24319952 8.616289e-20
resto        0.22646759 2.319804e-18
tea.time     0.19203800 1.652462e-15
price        0.21609382 4.050469e-14
pub          0.14722360 5.846592e-12
work         0.11153590 3.000872e-09
How          0.10285191 4.796010e-07
Tea          0.08950330 8.970954e-07
lunch        0.07458227 1.570629e-06
frequency    0.09438792 1.849071e-06
friendliness 0.07132511 2.706357e-06
evening      0.05311759 5.586801e-05
always       0.04479873 2.219503e-04
sex          0.03335969 1.487620e-03
dinner       0.03289362 1.608077e-03
breakfast    0.02539639 5.667604e-03
sugar        0.01527654 3.234986e-02
$`Dim 1`$category
                        Estimate      p.value
chain store+tea shop  0.33853776 1.344557e-35
tearoom               0.29731072 6.082138e-32
tea bag+unpackaged    0.23457030 1.361423e-21
friends               0.19950832 8.616289e-20
resto                 0.20802605 2.319804e-18
tea time              0.17011357 1.652462e-15
pub                   0.18137133 5.846592e-12
p_variable            0.27595067 5.956230e-12
work                  0.14170406 3.000872e-09
+2/day                0.14855615 7.380937e-07
lunch                 0.14862636 1.570629e-06
friendliness          0.13020388 2.706357e-06
other                 0.38192443 9.244911e-06
evening               0.09345270 5.586801e-05
always                0.08582336 2.219503e-04
F                     0.07158886 1.487620e-03
Not.dinner            0.13685745 1.608077e-03
lemon                 0.01223478 3.515252e-03
breakfast             0.06141392 5.667604e-03
senior                0.16802844 8.886876e-03
Earl Grey             0.12203299 1.547110e-02
No.sugar              0.04761975 3.234986e-02
sugar                -0.04761975 3.234986e-02
1 to 2/week          -0.10430402 1.829818e-02
p_private label      -0.11979263 1.156245e-02
Not.breakfast        -0.06141392 5.667604e-03
dinner               -0.13685745 1.608077e-03
M                    -0.07158886 1.487620e-03
alone                -0.23140428 2.326233e-04
Not.always           -0.08582336 2.219503e-04
1/day                -0.10038745 1.556219e-04
Not.evening          -0.09345270 5.586801e-05
Not.friendliness     -0.13020388 2.706357e-06
Not.lunch            -0.14862636 1.570629e-06
green                -0.24569103 1.281162e-07
Not.work             -0.14170406 3.000872e-09
p_branded            -0.10910793 1.116908e-09
Not.pub              -0.18137133 5.846592e-12
Not.tea time         -0.17011357 1.652462e-15
Not.resto            -0.20802605 2.319804e-18
Not.friends          -0.19950832 8.616289e-20
tea bag              -0.23182447 8.877561e-22
chain store          -0.24012436 3.008256e-27
Not.tearoom          -0.29731072 6.082138e-32

・・・・・・・・・・・・・・・
plotellipses(res.mca,keepvar=1:4) #6-1 plotellipses(res.mca,keepvar="Tea") #7-1
  #6-1

  #7-1


  FactoMineRのMCAを利用した多元表(tea)の多重対応分析  [ 目次に戻る ]