1. Importer les données

QteVie <- read.table("https://r-stat-sc-donnees.github.io/QteVie.csv", header = TRUE, sep = ";", quote = "", check.names = FALSE, row.names = 1, fileEncoding = "latin1")
summary(QteVie)
 Logements sans sanitaires Coût logement   Nb pièces par personne Revenu ménages 
 Min.   : 0.000            Min.   :11.00   Min.   :0.900          Min.   :11664  
 1st Qu.: 0.200            1st Qu.:19.75   1st Qu.:1.350          1st Qu.:18532  
 Median : 0.800            Median :21.00   Median :1.650          Median :23941  
 Mean   : 2.533            Mean   :20.83   Mean   :1.661          Mean   :24122  
 3rd Qu.: 3.825            3rd Qu.:22.00   3rd Qu.:1.925          3rd Qu.:28896  
 Max.   :15.100            Max.   :26.00   Max.   :2.500          Max.   :41355  
                                                                                 
 Patrimoine financier  Taux emploi    Sécurité emploi  Chômage longue durée
 Min.   :  3251       Min.   :49.00   Min.   : 2.400   Min.   : 0.010      
 1st Qu.: 14254       1st Qu.:61.00   1st Qu.: 4.250   1st Qu.: 1.325      
 Median : 31413       Median :67.00   Median : 5.150   Median : 1.940      
 Mean   : 40273       Mean   :66.39   Mean   : 5.672   Mean   : 3.535      
 3rd Qu.: 56322       3rd Qu.:72.00   3rd Qu.: 6.025   3rd Qu.: 3.908      
 Max.   :145769       Max.   :82.00   Max.   :17.800   Max.   :18.390      
                                                                           
 Revenus moyens activité Horaires travail lourds Qualité réseau social
 Min.   :16193           Min.   : 0.160          Min.   :72.00        
 1st Qu.:22517           1st Qu.: 3.640          1st Qu.:87.00        
 Median :35982           Median : 6.850          Median :90.00        
 Mean   :36054           Mean   : 9.156          Mean   :89.64        
 3rd Qu.:47713           3rd Qu.:12.363          3rd Qu.:94.00        
 Max.   :56340           Max.   :40.860          Max.   :96.00        
                                                                      
 Satisfaction sur la vie Temps aux loisirs et à soi Pollution atmosphérique
 Min.   :4.800           Min.   :13.42              Min.   : 9.00          
 1st Qu.:5.975           1st Qu.:14.58              1st Qu.:14.50          
 Median :6.850           Median :14.94              Median :18.00          
 Mean   :6.583           Mean   :14.88              Mean   :19.89          
 3rd Qu.:7.300           3rd Qu.:15.11              3rd Qu.:24.50          
 Max.   :7.500           Max.   :16.06              Max.   :46.00          
                                                                           
  Qualité eau    Espérance de vie Auto-évaluation état de santé Taux agression 
 Min.   :56.00   Min.   :70.20    Min.   :30.00                 Min.   : 1.30  
 1st Qu.:76.00   1st Qu.:78.58    1st Qu.:63.75                 1st Qu.: 2.55  
 Median :85.00   Median :81.00    Median :69.00                 Median : 3.75  
 Mean   :82.69   Mean   :79.74    Mean   :67.92                 Mean   : 4.05  
 3rd Qu.:91.25   3rd Qu.:81.58    3rd Qu.:76.25                 3rd Qu.: 5.00  
 Max.   :97.00   Max.   :83.20    Max.   :90.00                 Max.   :12.80  
                                                                               
 Taux homicides   Niveau instruction Compétences élèves Années scolarité
 Min.   : 0.300   Min.   :34.00      Min.   :402.0      Min.   :14.40   
 1st Qu.: 0.575   1st Qu.:71.75      1st Qu.:483.5      1st Qu.:16.40   
 Median : 0.900   Median :80.00      Median :498.5      Median :17.55   
 Mean   : 2.831   Mean   :75.36      Mean   :494.1      Mean   :17.49   
 3rd Qu.: 1.425   3rd Qu.:86.50      3rd Qu.:515.2      3rd Qu.:18.40   
 Max.   :25.500   Max.   :94.00      Max.   :542.0      Max.   :19.80   
                                                                        
          Région  
 Am Nord     : 3  
 Am Sud      : 2  
 Asie        : 3  
 Europe Est  : 7  
 Europe Nord : 5  
 Europe Ouest:14  
 Océanie     : 2  

2 et 3. Choisir les groupes de variables

library(FactoMineR)
afm <- MFA(QteVie, group = c(5,5,3,6,3,1), type = c(rep("s",5),"n"), name.group = c("Bien-être matériel","Emploi","Satisfaction","Santé et sécurité","Enseignement","Région"), num.group.sup = 6)

4. Choisir le nombre d’axes

barplot(afm$eig[,2], names = paste("Dim", 1:nrow(afm$eig)))

5. Analyser les résultats

summary(afm, nbelement = 10, nb.dec = 2, ncp = 2)

Call:
MFA(base = QteVie, group = c(5, 5, 3, 6, 3, 1), type = c(rep("s",  
     5), "n"), name.group = c("Bien-être matériel", "Emploi",  
     "Satisfaction", "Santé et sécurité", "Enseignement", "Région"),  
     num.group.sup = 6) 


Eigenvalues
                      Dim.1  Dim.2  Dim.3  Dim.4  Dim.5  Dim.6  Dim.7  Dim.8  Dim.9 Dim.10 Dim.11
Variance               3.37   1.29   1.04   0.78   0.51   0.40   0.39   0.25   0.23   0.16   0.13
% of var.             37.04  14.20  11.38   8.55   5.57   4.39   4.30   2.69   2.52   1.79   1.46
Cumulative % of var.  37.04  51.24  62.62  71.17  76.74  81.13  85.43  88.12  90.64  92.43  93.89
                     Dim.12 Dim.13 Dim.14 Dim.15 Dim.16 Dim.17 Dim.18 Dim.19 Dim.20 Dim.21 Dim.22
Variance               0.10   0.10   0.09   0.07   0.06   0.04   0.03   0.03   0.02   0.02   0.00
% of var.              1.13   1.06   1.02   0.72   0.61   0.46   0.38   0.31   0.21   0.17   0.03
Cumulative % of var.  95.02  96.09  97.11  97.83  98.44  98.90  99.28  99.58  99.80  99.97 100.00

Groups
                            Dim.1   ctr  cos2   Dim.2   ctr  cos2  
Bien-être matériel        |  0.76 22.46  0.47 |  0.10  7.79  0.01 |
Emploi                    |  0.62 18.33  0.28 |  0.68 52.27  0.34 |
Satisfaction              |  0.61 18.20  0.29 |  0.30 23.01  0.07 |
Santé et sécurité         |  0.84 24.77  0.52 |  0.12  9.01  0.01 |
Enseignement              |  0.55 16.24  0.25 |  0.10  7.92  0.01 |

Supplementary group
                            Dim.1 cos2   Dim.2 cos2  
Région                    |  0.47 0.04 |  0.34 0.02 |

Individuals (the 10 first)
                            Dim.1   ctr  cos2   Dim.2   ctr  cos2  
Allemagne                 |  1.74  2.50  0.80 |  0.15  0.05  0.01 |
Australie                 |  1.83  2.75  0.53 |  0.65  0.91  0.07 |
Autriche                  |  0.76  0.48  0.22 |  0.83  1.48  0.25 |
Belgique                  |  1.37  1.55  0.36 | -0.39  0.33  0.03 |
Brésil                    | -2.71  6.04  0.39 |  1.41  4.29  0.11 |
Canada                    |  1.90  2.97  0.52 |  0.69  1.03  0.07 |
Chili                     | -2.70  6.01  0.60 |  1.09  2.53  0.10 |
Corée                     | -1.29  1.37  0.11 |  0.38  0.32  0.01 |
Danemark                  |  2.07  3.51  0.55 | -0.42  0.38  0.02 |
Espagne                   | -0.11  0.01  0.00 | -2.96 18.78  0.53 |

Continuous variables (the 10 first)
                            Dim.1   ctr  cos2   Dim.2   ctr  cos2  
Logements sans sanitaires | -0.70  5.06  0.49 |  0.26  1.84  0.07 |
Coût logement             |  0.16  0.26  0.02 | -0.32  2.82  0.10 |
Nb pièces par personne    |  0.79  6.40  0.62 |  0.09  0.24  0.01 |
Revenu ménages            |  0.82  6.94  0.67 |  0.19  0.96  0.04 |
Patrimoine financier      |  0.61  3.81  0.37 |  0.27  1.94  0.07 |
Taux emploi               |  0.68  5.35  0.46 |  0.53  8.52  0.28 |
Sécurité emploi           | -0.19  0.43  0.04 | -0.71 15.13  0.50 |
Chômage longue durée      | -0.21  0.51  0.04 | -0.88 23.24  0.77 |
Revenus moyens activité   |  0.87  8.80  0.76 |  0.17  0.89  0.03 |
Horaires travail lourds   | -0.53  3.24  0.28 |  0.39  4.48  0.15 |

Supplementary categories
                            Dim.1  cos2 v.test   Dim.2  cos2 v.test  
Am Nord                   | -0.37  0.03  -0.36 |  1.49  0.50   2.33 |
Am Sud                    | -2.71  0.61  -2.11 |  1.25  0.13   1.58 |
Asie                      | -1.74  0.37  -1.69 |  0.45  0.03   0.71 |
Europe Est                | -1.01  0.37  -1.60 | -0.30  0.03  -0.77 |
Europe Nord               |  1.85  0.74   2.40 |  0.11  0.00   0.23 |
Europe Ouest              |  0.45  0.25   1.15 | -0.56  0.39  -2.31 |
Océanie                   |  1.66  0.55   1.29 |  0.51  0.05   0.65 |
round(afm$group$RV, 2)
                   Bien-être matériel Emploi Satisfaction Santé et sécurité Enseignement Région
Bien-être matériel               1.00   0.39         0.32              0.56         0.20   0.22
Emploi                           0.39   1.00         0.46              0.35         0.26   0.23
Satisfaction                     0.32   0.46         1.00              0.34         0.15   0.25
Santé et sécurité                0.56   0.35         0.34              1.00         0.51   0.30
Enseignement                     0.20   0.26         0.15              0.51         1.00   0.24
Région                           0.22   0.23         0.25              0.30         0.24   1.00
MFA                              0.71   0.71         0.65              0.79         0.60   0.36
                    MFA
Bien-être matériel 0.71
Emploi             0.71
Satisfaction       0.65
Santé et sécurité  0.79
Enseignement       0.60
Région             0.36
MFA                1.00
plot(afm, partial = c("France","Autriche"), invisible = "quali")

plot(afm, invisible = "quali", partial = "all", xlim = c(-5,5),
     ylim = c(-5,5), 
     palette = palette(c("black", "transparent", "transparent", "blue", "transparent", "transparent")),
     title = "Graphe des points partiels sur la satisfaction")

Factoshiny

library(Factoshiny)
res.shiny <- MFAshiny(QteVie)
LS0tDQp0aXRsZTogIkFuYWx5c2UgRmFjdG9yaWVsbGUgTXVsdGlwbGUiDQphdXRob3I6ICJIdXNzb24gZXQgYWwuIg0KZGF0ZTogIjA1LzA5LzIwMTgiDQpvdXRwdXQ6DQogIGh0bWxfbm90ZWJvb2s6DQogICAgdG9jOiB5ZXMNCiAgICB0b2NfZGVwdGg6IDMNCiAgICB0b2NfZmxvYXQ6IHllcw0KICBodG1sX2RvY3VtZW50Og0KICAgIHRvYzogeWVzDQogICAgdG9jX2RlcHRoOiAnMycNCiAgICB0b2NfZmxvYXQ6IHllcw0KLS0tDQoNCiMgMS4gSW1wb3J0ZXIgbGVzIGRvbm7DqWVzDQoNCmBgYHtyfQ0KUXRlVmllIDwtIHJlYWQudGFibGUoImh0dHBzOi8vci1zdGF0LXNjLWRvbm5lZXMuZ2l0aHViLmlvL1F0ZVZpZS5jc3YiLCBoZWFkZXIgPSBUUlVFLCBzZXAgPSAiOyIsIHF1b3RlID0gIiIsIGNoZWNrLm5hbWVzID0gRkFMU0UsIHJvdy5uYW1lcyA9IDEsIGZpbGVFbmNvZGluZyA9ICJsYXRpbjEiKQ0Kc3VtbWFyeShRdGVWaWUpDQpgYGANCg0KDQoNCiMgMiBldCA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