R language Access Menu

Title Text Both  

Multiple correpondence analysis

Multiple correspondence analysis can show relation between categories of multiple categorical variables at one time. For example, we can show relation between all categorical variables of bwdf dataset: 

Code:

> str(bwdf)
'data.frame':   189 obs. of  9 variables:
 $ low  : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
 $ age  : int  19 33 20 21 18 21 22 17 29 26 ...
 $ lwt  : int  182 155 105 108 107 124 118 103 123 113 ...
 $ race : Factor w/ 3 levels "1","2","3": 2 3 1 1 1 3 1 3 1 1 ...
 $ smoke: Factor w/ 2 levels "0","1": 1 1 2 2 2 1 1 1 2 2 ...
 $ ptl  : int  0 0 0 0 0 0 0 0 0 0 ...
 $ ht   : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
 $ ui   : Factor w/ 2 levels "0","1": 2 1 1 2 2 1 1 1 1 1 ...
 $ ftv  : int  0 3 1 2 0 0 1 1 1 0 ...

> library(FactoMineR)
> res = MCA(bwdf[c('low','race','smoke','ht','ui')])
> res$eig
      eigenvalue percentage of variance cumulative percentage of variance
dim 1  0.2687779              22.398154                          22.39815
dim 2  0.2557932              21.316099                          43.71425
dim 3  0.2313479              19.278995                          62.99325
dim 4  0.1860591              15.504926                          78.49817
dim 5  0.1475507              12.295890                          90.79406
dim 6  0.1104712               9.205936                         100.00000

The first 2 dimensions (which are similar to components of principal component analysis) account for 43.7% of variance in these variables. The biplot of variables is also plotted alongwith above command: 


References:
Francois Husson, Julie Josse, Sebastien Le and Jeremy Mazet (2014). FactoMineR: Multivariate Exploratory Data Analysis and Data Mining with R. R package version 1.27. http://CRAN.R-project.org/package=FactoMineR

Output graph:

                      

It shows that low_1 (category 1 of 'low' variable) is related to ht_1, ui_1 and race_2. 


    Comments & Feedback