Analyse des données decathlon

#Importation des données Dans ce TP, on va utiliser le dataset decathlon qui existe dans le package FactoMineR. https://malouche.github.io/data_in_class/decathlon_data.html

library(FactoMineR)
data("decathlon")
View(decathlon)

Description des données

## 'data.frame':    41 obs. of  13 variables:
##  $ 100m       : num  11 10.8 11 11 11.3 ...
##  $ Long.jump  : num  7.58 7.4 7.3 7.23 7.09 7.6 7.3 7.31 6.81 7.56 ...
##  $ Shot.put   : num  14.8 14.3 14.8 14.2 15.2 ...
##  $ High.jump  : num  2.07 1.86 2.04 1.92 2.1 1.98 2.01 2.13 1.95 1.86 ...
##  $ 400m       : num  49.8 49.4 48.4 48.9 50.4 ...
##  $ 110m.hurdle: num  14.7 14.1 14.1 15 15.3 ...
##  $ Discus     : num  43.8 50.7 49 40.9 46.3 ...
##  $ Pole.vault : num  5.02 4.92 4.92 5.32 4.72 4.92 4.42 4.42 4.92 4.82 ...
##  $ Javeline   : num  63.2 60.1 50.3 62.8 63.4 ...
##  $ 1500m      : num  292 302 300 280 276 ...
##  $ Rank       : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ Points     : int  8217 8122 8099 8067 8036 8030 8004 7995 7802 7733 ...
##  $ Competition: Factor w/ 2 levels "Decastar","OlympicG": 1 1 1 1 1 1 1 1 1 1 ...
##       100m         Long.jump       Shot.put       High.jump          400m      
##  Min.   :10.44   Min.   :6.61   Min.   :12.68   Min.   :1.850   Min.   :46.81  
##  1st Qu.:10.85   1st Qu.:7.03   1st Qu.:13.88   1st Qu.:1.920   1st Qu.:48.93  
##  Median :10.98   Median :7.30   Median :14.57   Median :1.950   Median :49.40  
##  Mean   :11.00   Mean   :7.26   Mean   :14.48   Mean   :1.977   Mean   :49.62  
##  3rd Qu.:11.14   3rd Qu.:7.48   3rd Qu.:14.97   3rd Qu.:2.040   3rd Qu.:50.30  
##  Max.   :11.64   Max.   :7.96   Max.   :16.36   Max.   :2.150   Max.   :53.20  
##   110m.hurdle        Discus        Pole.vault       Javeline    
##  Min.   :13.97   Min.   :37.92   Min.   :4.200   Min.   :50.31  
##  1st Qu.:14.21   1st Qu.:41.90   1st Qu.:4.500   1st Qu.:55.27  
##  Median :14.48   Median :44.41   Median :4.800   Median :58.36  
##  Mean   :14.61   Mean   :44.33   Mean   :4.762   Mean   :58.32  
##  3rd Qu.:14.98   3rd Qu.:46.07   3rd Qu.:4.920   3rd Qu.:60.89  
##  Max.   :15.67   Max.   :51.65   Max.   :5.400   Max.   :70.52  
##      1500m            Rank           Points       Competition
##  Min.   :262.1   Min.   : 1.00   Min.   :7313   Decastar:13  
##  1st Qu.:271.0   1st Qu.: 6.00   1st Qu.:7802   OlympicG:28  
##  Median :278.1   Median :11.00   Median :8021                
##  Mean   :279.0   Mean   :12.12   Mean   :8005                
##  3rd Qu.:285.1   3rd Qu.:18.00   3rd Qu.:8122                
##  Max.   :317.0   Max.   :28.00   Max.   :8893

Analyse univariée High Jump (quatitative continue)

hist(decathlon$High.jump)

boxplot(decathlon$High.jump)

# Analyse univariée competition (qualitative)

barplot(table(decathlon$Competition))

pie(table(decathlon$Competition))

#q3

library(plyr)
ddply(decathlon,c("Competition"), summarise, moyLJ=mean(Long.jump), varSP=var(Shot.put), sdHJ=sd(High.jump))
##   Competition    moyLJ     varSP       sdHJ
## 1    Decastar 7.247692 0.4550641 0.09038380
## 2    OlympicG 7.265714 0.7331148 0.08994707

#q4 Data scaling = normalisation des données : centrer trancher la moyenne , reduire diviser par ecart type

decathlon2=scale(decathlon[,-c(13)], center = TRUE, scale =TRUE)
View(decathlon2)
X=cbind.data.frame(decathlon2,decathlon$Competition)
colnames(X)=colnames(decathlon)

#q5 representation graphiqye des croisements competition chaque sport

library(reshape2)
dfmelt=melt(X,measure.vars=1:12)
View(dfmelt)
library (ggplot2)
p =ggplot(dfmelt,aes(x=Competition , y = value,fill =Competition))+geom_boxplot()+ facet_wrap(~variable)
p

#q6: etude de correlation

cor(decathlon2)
##                    100m   Long.jump    Shot.put   High.jump         400m
## 100m         1.00000000 -0.59867767 -0.35648227 -0.24625292  0.520298155
## Long.jump   -0.59867767  1.00000000  0.18330436  0.29464444 -0.602062618
## Shot.put    -0.35648227  0.18330436  1.00000000  0.48921153 -0.138432919
## High.jump   -0.24625292  0.29464444  0.48921153  1.00000000 -0.187956928
## 400m         0.52029815 -0.60206262 -0.13843292 -0.18795693  1.000000000
## 110m.hurdle  0.57988893 -0.50541009 -0.25161571 -0.28328909  0.547987756
## Discus      -0.22170757  0.19431009  0.61576810  0.36921834 -0.117879365
## Pole.vault  -0.08253683  0.20401411  0.06118185 -0.15618074 -0.079292469
## Javeline    -0.15774645  0.11975893  0.37495551  0.17188009  0.004232096
## 1500m       -0.06054645 -0.03368613  0.11580306 -0.04490252  0.408106432
## Rank         0.29670366 -0.60405452 -0.36996958 -0.49276873  0.562118543
## Points      -0.68427243  0.72513490  0.62738936  0.57670316 -0.666939955
##              110m.hurdle     Discus   Pole.vault     Javeline       1500m
## 100m         0.579888931 -0.2217076 -0.082536834 -0.157746452 -0.06054645
## Long.jump   -0.505410086  0.1943101  0.204014112  0.119758933 -0.03368613
## Shot.put    -0.251615714  0.6157681  0.061181853  0.374955509  0.11580306
## High.jump   -0.283289090  0.3692183 -0.156180742  0.171880092 -0.04490252
## 400m         0.547987756 -0.1178794 -0.079292469  0.004232096  0.40810643
## 110m.hurdle  1.000000000 -0.3262010 -0.002703885  0.008743251  0.03754024
## Discus      -0.326200961  1.0000000 -0.150072400  0.157889799  0.25817510
## Pole.vault  -0.002703885 -0.1500724  1.000000000 -0.030000603  0.24744778
## Javeline     0.008743251  0.1578898 -0.030000603  1.000000000 -0.18039313
## 1500m        0.037540240  0.2581751  0.247447780 -0.180393128  1.00000000
## Rank         0.439102281 -0.3891251 -0.320379567 -0.208094646  0.08989781
## Points      -0.644460200  0.4841830  0.197436342  0.422393176 -0.19434860
##                    Rank     Points
## 100m         0.29670366 -0.6842724
## Long.jump   -0.60405452  0.7251349
## Shot.put    -0.36996958  0.6273894
## High.jump   -0.49276873  0.5767032
## 400m         0.56211854 -0.6669400
## 110m.hurdle  0.43910228 -0.6444602
## Discus      -0.38912515  0.4841830
## Pole.vault  -0.32037957  0.1974363
## Javeline    -0.20809465  0.4223932
## 1500m        0.08989781 -0.1943486
## Rank         1.00000000 -0.7391835
## Points      -0.73918347  1.0000000
library(corrgram)
## 
## Attachement du package : 'corrgram'
## L'objet suivant est masqué depuis 'package:plyr':
## 
##     baseball
corrgram(X[,-c(13)], order = TRUE, lower.panel = panel.conf)
## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

## Warning in par(usr): argument 1 does not name a graphical parameter

etape de l’ACP

etape 1: normalisation centre et réduire les variables actives (intéréts)

dataset: variable qualitative supplémentaire (compétition) variable quantitative active: des données (informations) brutes non déduites à partir d’autres (cad majebnehomch mn d’autres variables tel que points , rank) variable quantitative supplémentair: déduite à partir d’autres variables(somme points , rank , average…) on va travailler sur les 10 premiéres variables actives

# centrer les données
g = colMeans(decathlon [,1:10])
g
##        100m   Long.jump    Shot.put   High.jump        400m 110m.hurdle 
##   10.998049    7.260000   14.477073    1.976829   49.616341   14.605854 
##      Discus  Pole.vault    Javeline       1500m 
##   44.325610    4.762439   58.316585  279.024878
x22 = sweep(decathlon [,1:10], MARGIN = 2, STATS = g, FUN = "-")
round(colMeans(x22) , 3)
##        100m   Long.jump    Shot.put   High.jump        400m 110m.hurdle 
##           0           0           0           0           0           0 
##      Discus  Pole.vault    Javeline       1500m 
##           0           0           0           0
x22
##                    100m Long.jump     Shot.put    High.jump        400m
## SEBRLE       0.04195122      0.32  0.352926829  0.093170732  0.19365854
## CLAY        -0.23804878      0.14 -0.217073171 -0.116829268 -0.24634146
## KARPOV       0.02195122      0.04  0.292926829  0.063170732 -1.24634146
## BERNARD      0.02195122     -0.03 -0.227073171 -0.056829268 -0.68634146
## YURKOV       0.34195122     -0.17  0.712926829  0.123170732  0.80365854
## WARNERS      0.11195122      0.34 -0.167073171  0.003170732 -0.93634146
## ZSIVOCZKY    0.13195122      0.04 -0.997073171  0.033170732 -0.99634146
## McMULLEN    -0.16804878      0.05 -0.717073171  0.153170732  0.29365854
## MARTINEAU    0.64195122     -0.45  0.092926829 -0.026829268  0.52365854
## HERNU        0.37195122      0.30 -0.067073171 -0.116829268  1.48365854
## BARRAS       0.33195122     -0.29 -0.387073171 -0.026829268 -0.13634146
## NOOL         0.33195122      0.01 -1.797073171  0.003170732 -0.41634146
## BOURGUIGNON  0.36195122     -0.46 -1.017073171 -0.116829268  1.54365854
## Sebrle      -0.14804878      0.58  1.882926829  0.143170732 -1.25634146
## Clay        -0.55804878      0.70  0.752926829  0.083170732 -0.42634146
## Karpov      -0.49804878      0.55  1.452926829  0.113170732 -2.80634146
## Macey       -0.10804878      0.21  1.252926829  0.173170732 -0.64634146
## Warners     -0.37804878      0.48  0.002926829 -0.006829268 -1.64634146
## Zsivoczky   -0.08804878     -0.12  0.832926829  0.143170732 -0.21634146
## Hernu       -0.02804878     -0.07  0.172926829  0.053170732 -0.88634146
## Nool        -0.19804878      0.27 -0.217073171 -0.096829268 -0.80634146
## Bernard     -0.30804878      0.22  0.322926829  0.143170732 -0.48634146
## Schwarzl    -0.01804878      0.23 -0.467073171 -0.036829268  0.14365854
## Pogorelov   -0.04804878      0.05  0.622926829  0.083170732  1.17365854
## Schoenbeck  -0.09804878      0.04  0.292926829 -0.096829268  0.68365854
## Barras       0.14195122     -0.27  0.432926829 -0.036829268 -0.20634146
## Smith       -0.14804878     -0.45  0.762926829 -0.066829268 -0.34634146
## Averyanov   -0.44804878      0.08 -0.037073171 -0.036829268  0.10365854
## Ojaniemi    -0.31804878      0.24  0.492926829 -0.036829268 -0.49634146
## Smirnov     -0.10804878     -0.19 -0.597073171 -0.036829268 -0.50634146
## Qi           0.06195122      0.08 -0.927073171 -0.006829268  0.03365854
## Drews       -0.12804878      0.12 -1.407073171 -0.096829268 -1.10634146
## Parkhomenko  0.14195122     -0.65  1.212926829  0.053170732  1.42365854
## Terek       -0.07804878     -0.32  0.672926829 -0.036829268 -0.05634146
## Gomez        0.08195122      0.00  0.092926829 -0.126829268 -1.00634146
## Turi         0.08195122     -0.35 -0.857073171  0.053170732  2.05365854
## Lorenzo      0.10195122     -0.23 -1.257073171 -0.126829268 -0.27634146
## Karlivans    0.33195122      0.00 -1.177073171 -0.006829268  0.92365854
## Korkizoglou -0.13804878     -0.19  0.332926829 -0.036829268  1.54365854
## Uldal        0.23195122     -0.27 -0.947073171 -0.126829268  1.33365854
## Casarsa      0.36195122     -0.58  0.442926829 -0.036829268  3.58365854
##             110m.hurdle      Discus  Pole.vault    Javeline      1500m
## SEBRLE       0.08414634 -0.57560976  0.25756098  4.87341463  12.675122
## CLAY        -0.55585366  6.39439024  0.15756098  1.83341463  22.475122
## KARPOV      -0.51585366  4.62439024  0.15756098 -8.00658537  21.175122
## BERNARD      0.38414634 -3.45560976  0.55756098  4.45341463   1.075122
## YURKOV       0.70414634  1.93439024 -0.04243902  5.12341463  -2.624878
## WARNERS     -0.37585366 -3.22560976  0.15756098 -6.54658537  -0.924878
## ZSIVOCZKY   -0.43585366  1.34439024 -0.34243902 -2.94658537 -11.024878
## McMULLEN    -0.22585366  0.08439024 -0.34243902 -1.94658537   6.075122
## MARTINEAU    0.32414634  3.27439024  0.15756098 -5.98658537 -16.924878
## HERNU        0.45414634  0.66439024  0.05756098 -1.12658537   6.075122
## BARRAS      -0.12585366 -2.22560976 -0.04243902 -2.91658537   2.975122
## NOOL         0.68414634 -6.40560976 -0.14243902 -0.87658537 -12.424878
## BOURGUIGNON  1.06414634 -3.83560976  0.25756098 -3.63658537  12.675122
## Sebrle      -0.55585366  4.39439024  0.23756098 12.20341463   0.985122
## Clay        -0.47585366  5.78439024  0.13756098 11.39341463   2.975122
## Karpov      -0.63585366  7.32439024 -0.16243902 -2.77658537  -0.914878
## Macey       -0.04585366  4.01439024 -0.36243902  0.14341463 -13.604878
## Warners     -0.59585366 -0.59560976  0.13756098 -2.92658537  -0.974878
## Zsivoczky    0.34414634  1.29439024 -0.06243902  5.13341463  -9.484878
## Hernu       -0.35585366  0.39439024  0.03756098 -0.55658537 -14.674878
## Nool         0.19414634 -2.27560976  0.63756098  3.01341463  -2.694878
## Bernard     -0.43585366  0.42439024 -0.36243902 -3.04658537  -2.714878
## Schwarzl    -0.35585366 -1.89560976  0.33756098 -1.99658537  -5.464878
## Pogorelov   -0.39585366  0.27439024  0.23756098 -4.86658537   8.605122
## Schoenbeck  -0.26585366  0.08439024  0.23756098  2.57341463  -0.204878
## Barras      -0.23585366  0.50439024 -0.16243902  6.23341463 -11.934878
## Smith       -0.59585366  4.69439024 -0.56243902  3.20341463  -6.284878
## Averyanov   -0.21585366 -4.44560976  0.03756098 -3.80658537  -8.004878
## Ojaniemi     0.40414634 -3.97560976 -0.16243902  0.94341463  -3.314878
## Smirnov      0.16414634 -1.85560976 -0.06243902  2.56341463 -15.714878
## Qi           0.17414634  0.80439024 -0.26243902  2.47341463  -6.394878
## Drews       -0.59585366 -4.21560976  0.23756098 -6.78658537  -4.814878
## Parkhomenko  0.27414634 -2.42560976  0.03756098  7.50341463  -1.084878
## Terek        0.51414634  1.29439024  0.53756098 -7.69658537  11.335122
## Gomez       -0.19585366 -3.37560976 -0.36243902  2.39341463  -9.324878
## Turi        -0.34585366 -4.49560976  0.03756098  1.02341463  10.985122
## Lorenzo      0.77414634 -4.10560976 -0.26243902  0.04341463 -15.944878
## Karlivans    0.37414634 -0.98560976 -0.26243902 -5.39658537  -0.354878
## Korkizoglou  0.35414634  1.74439024 -0.06243902 -5.26658537  37.975122
## Uldal        0.48414634 -1.31560976 -0.26243902  1.68341463   2.675122
## Casarsa      0.78414634  4.33439024 -0.36243902  0.30341463  17.095122