library(FactoMineR)
## Warning: package 'FactoMineR' was built under R version 4.0.3
library(factoextra)
## Loading required package: ggplot2
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
read.table("perros.txt",header=T,sep="",row.names=1)->perrosi

Descripción del Conjunto de datos

En este informe se realizará una aplicación del ACM utilizando el conjunto de datos “perros”. Este conjunto de datos presenta 27 razas de perros y 7 variables cualitativas. A continuación, se presenta el conjunto de datos.

knitr::kable(perrosi)
TAM PES VEL INT AFE AGR FUN
bass peq liv len baj baj alt caz
beau gra med alt med alt alt uti
boxe med med med med alt alt com
buld peq liv len med alt baj com
bulm gra pes len alt baj alt uti
cani peq liv med alt alt baj com
chih peq liv len baj alt baj com
cock med liv len med alt alt com
coll gra med alt med alt baj com
dalm med med med med alt baj com
dobe gra med alt alt baj alt uti
dogo gra pes alt baj baj alt uti
foxh gra med alt baj baj alt caz
foxt peq liv med med alt alt com
galg gra med alt baj baj baj caz
gasc gra med med baj baj alt caz
labr med med med med alt baj caz
masa gra med alt alt alt alt uti
mast gra pes len baj baj alt uti
peki peq liv len baj alt baj com
podb med med med alt alt baj caz
podf gra med med med baj baj caz
poin gra med alt alt baj baj caz
sett gra med alt med baj baj caz
stbe gra pes len med baj alt uti
teck peq liv len med alt baj com
tern gra pes len med baj baj uti

Estadisticas Descriptivas

par(mfrow=c(3,3))
barplot(table(perrosi$TAM),col=2)
barplot(table(perrosi$PES),col=3)
barplot(table(perrosi$VEL),col=4)
barplot(table(perrosi$INT),col=5)
barplot(table(perrosi$AFE),col=6)
barplot(table(perrosi$AGR),col=7)
barplot(table(perrosi$FUN),col=8)

Análisis Bivariados

chisq.test(table(perrosi$TAM,perrosi$PES))
## Warning in chisq.test(table(perrosi$TAM, perrosi$PES)): Chi-squared
## approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  table(perrosi$TAM, perrosi$PES)
## X-squared = 25.329, df = 4, p-value = 4.321e-05
chisq.test(table(perrosi$TAM,perrosi$VEL))
## Warning in chisq.test(table(perrosi$TAM, perrosi$VEL)): Chi-squared
## approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  table(perrosi$TAM, perrosi$VEL)
## X-squared = 15.891, df = 4, p-value = 0.003168
chisq.test(table(perrosi$TAM,perrosi$INT))
## Warning in chisq.test(table(perrosi$TAM, perrosi$INT)): Chi-squared
## approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  table(perrosi$TAM, perrosi$INT)
## X-squared = 3.6082, df = 4, p-value = 0.4616
chisq.test(table(perrosi$TAM,perrosi$AFE))
## Warning in chisq.test(table(perrosi$TAM, perrosi$AFE)): Chi-squared
## approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  table(perrosi$TAM, perrosi$AFE)
## X-squared = 13.954, df = 2, p-value = 0.0009333
chisq.test(table(perrosi$TAM,perrosi$AGR))
## Warning in chisq.test(table(perrosi$TAM, perrosi$AGR)): Chi-squared
## approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  table(perrosi$TAM, perrosi$AGR)
## X-squared = 2.0515, df = 2, p-value = 0.3585
chisq.test(table(perrosi$TAM,perrosi$FUN))
## Warning in chisq.test(table(perrosi$TAM, perrosi$FUN)): Chi-squared
## approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  table(perrosi$TAM, perrosi$FUN)
## X-squared = 16.354, df = 4, p-value = 0.002579

Analisis Multivariado ACM

res.ACM.perros <- MCA(perrosi,quali.sup = 7,graph = TRUE)

fviz_mca_biplot(res.ACM.perros,repel=TRUE)

Contribucciones

fviz_contrib(res.ACM.perros,choice="var",axes=1)

fviz_contrib(res.ACM.perros,choice="var",axes=2)

fviz_contrib(res.ACM.perros,choice="var",axes=3)

fviz_contrib(res.ACM.perros,choice="ind",axes=1)

fviz_contrib(res.ACM.perros,choice="ind",axes=2)

fviz_contrib(res.ACM.perros,choice="ind",axes=3)

#### COSENOS CUADRADOS

res.ACM.perros$var$cos2
##              Dim 1        Dim 2       Dim 3       Dim 4        Dim 5
## TAM_gra 0.87503205 0.0005293413 0.003279033 0.036219310 1.586620e-02
## TAM_med 0.16462520 0.3448030588 0.234627550 0.026653716 2.184658e-02
## TAM_peq 0.49144201 0.2987546600 0.132809435 0.005052544 1.394894e-04
## PES_liv 0.57531341 0.2861238116 0.054196308 0.011447021 1.104688e-03
## PES_med 0.10044717 0.7221387844 0.057601141 0.015087719 3.895941e-02
## PES_pes 0.23420393 0.2155641859 0.339157541 0.001038734 8.582564e-02
## VEL_alt 0.39792110 0.0691296921 0.291151283 0.028763587 5.089122e-05
## VEL_len 0.06021292 0.6422447857 0.094932948 0.003795952 5.504701e-02
## VEL_med 0.15344741 0.3318791146 0.053456249 0.057717964 5.796523e-02
## INT_alt 0.03207684 0.0603213262 0.102831012 0.464645451 3.229645e-01
## INT_baj 0.05129787 0.2752677726 0.052025334 0.000247354 4.510944e-01
## INT_med 0.12673870 0.0756897524 0.225873819 0.338187895 1.986299e-02
## AFE_alt 0.64765585 0.0767360421 0.003980589 0.006420928 1.750915e-03
## AFE_baj 0.64765585 0.0767360421 0.003980589 0.006420928 1.750915e-03
## AGR_alt 0.17292377 0.0406368567 0.103307716 0.282075371 1.302074e-01
## AGR_baj 0.17292377 0.0406368567 0.103307716 0.282075371 1.302074e-01
fviz_cos2(res.ACM.perros,choice="var",axes=1)

fviz_cos2(res.ACM.perros,choice="var",axes=2)

fviz_cos2(res.ACM.perros,choice="var",axes=3)

Cluster

cluster <- HCPC(res.ACM.perros,nb.clust=-1)

cluster$desc.var
## 
## Link between the cluster variable and the categorical variables (chi-square test)
## =================================================================================
##          p.value df
## TAM 7.377151e-10  6
## PES 5.258626e-09  6
## VEL 2.530335e-04  6
## FUN 2.691927e-04  6
## AFE 1.688726e-03  3
## 
## Description of each cluster by the categories
## =============================================
## $`1`
##               Cla/Mod Mod/Cla   Global      p.value    v.test
## PES=PES_pes 100.00000     100 18.51852 1.238697e-05  4.370663
## FUN=uti      62.50000     100 29.62963 6.936703e-04  3.392069
## AFE=AFE_baj  38.46154     100 48.14815 1.594203e-02  2.410240
## TAM=TAM_gra  33.33333     100 55.55556 3.719807e-02  2.083584
## AFE=AFE_alt   0.00000       0 51.85185 1.594203e-02 -2.410240
## PES=PES_med   0.00000       0 51.85185 1.594203e-02 -2.410240
## 
## $`2`
##              Cla/Mod Mod/Cla   Global      p.value    v.test
## PES=PES_med 71.42857     100 51.85185 0.0001186541  3.848890
## VEL=VEL_alt 88.88889      80 33.33333 0.0001674908  3.763591
## TAM=TAM_gra 66.66667     100 55.55556 0.0003559624  3.570749
## FUN=caz     66.66667      60 33.33333 0.0377633046  2.077415
## FUN=com     10.00000      10 37.03704 0.0334265616 -2.126922
## TAM=TAM_peq  0.00000       0 25.92593 0.0219001610 -2.292095
## PES=PES_liv  0.00000       0 29.62963 0.0109500805 -2.544288
## VEL=VEL_len  0.00000       0 37.03704 0.0023052801 -3.047794
## 
## $`3`
##               Cla/Mod Mod/Cla   Global      p.value    v.test
## TAM=TAM_med 100.00000     100 18.51852 1.238697e-05  4.370663
## VEL=VEL_med  50.00000      80 29.62963 1.786201e-02  2.368466
## AFE=AFE_alt  35.71429     100 51.85185 2.479871e-02  2.244524
## AFE=AFE_baj   0.00000       0 48.14815 2.479871e-02 -2.244524
## TAM=TAM_gra   0.00000       0 55.55556 9.810479e-03 -2.582439
## 
## $`4`
##             Cla/Mod   Mod/Cla   Global      p.value    v.test
## TAM=TAM_peq   100.0 100.00000 25.92593 1.126088e-06  4.868218
## PES=PES_liv    87.5 100.00000 29.62963 9.008705e-06  4.439694
## FUN=com        60.0  85.71429 37.03704 4.290396e-03  2.855982
## VEL=VEL_len    50.0  71.42857 37.03704 4.690382e-02  1.987168
## VEL=VEL_alt     0.0   0.00000 33.33333 3.583663e-02 -2.098776
## PES=PES_med     0.0   0.00000 51.85185 1.932367e-03 -3.100435
## TAM=TAM_gra     0.0   0.00000 55.55556 8.918618e-04 -3.322589