#Chapitre 2 : solution des exercices

library(BioStatR)

data("Quetelet")
Quetelet$BMI=with(Quetelet,poids/(taille/100)^2)

library(MVN)
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
## sROC 0.1-2 loaded
mvn(Quetelet[,-1], mvnTest = "mardia",
    univariateTest = "SW", univariatePlot = "histogram",
    multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = TRUE, showNewData = TRUE)

## $multivariateNormality
##              Test        Statistic              p value Result
## 1 Mardia Skewness 69.6790258334751 5.11364246753169e-11     NO
## 2 Mardia Kurtosis 5.38926570325248   7.074614538638e-08     NO
## 3             MVN             <NA>                 <NA>     NO
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk   poids      0.9399    0.0031    NO    
## 2 Shapiro-Wilk  taille      0.9877    0.7585    YES   
## 3 Shapiro-Wilk    BMI       0.9802    0.3741    YES   
## 
## $Descriptives
##         n      Mean   Std.Dev    Median       Min       Max      25th
## poids  66  64.51515 11.116505  65.50000  47.00000  86.00000  53.00000
## taille 66 174.06061  9.313148 174.50000 150.00000 200.00000 168.00000
## BMI    66  21.15609  2.266562  20.89342  16.91723  26.76978  19.52229
##             75th        Skew    Kurtosis
## poids   73.00000  0.04322566 -1.26787864
## taille 180.00000 -0.05066418 -0.09962364
## BMI     22.38163  0.35034822 -0.50614393
## 
## $multivariateOutliers
##    Observation Mahalanobis Distance Outlier
## 65          65               34.446    TRUE
## 54          54               30.836    TRUE
## 12          12               27.148    TRUE
## 7            7               24.711    TRUE
## 21          21               24.213    TRUE
## 6            6               18.274    TRUE
## 42          42               17.442    TRUE
## 31          31               17.024    TRUE
## 22          22               16.455    TRUE
## 16          16               15.875    TRUE
## 9            9               12.458    TRUE
## 
## $newData
##    poids taille      BMI
## 1     60    170 20.76125
## 10    64    175 20.89796
## 11    53    165 19.46740
## 13    61    175 19.91837
## 14    78    184 23.03875
## 15    68    178 21.46194
## 17    53    164 19.70553
## 18    79    179 24.65591
## 19    74    182 22.34030
## 2     57    169 19.95728
## 20    62    174 20.47827
## 23    74    172 25.01352
## 24    80    185 23.37473
## 25    53    170 18.33910
## 26    73    178 23.04002
## 27    70    180 21.60494
## 28    72    189 20.15621
## 29    70    172 23.66144
## 3     51    172 17.23905
## 30    62    174 20.47827
## 32    70    178 22.09317
## 33    76    178 23.98687
## 34    51    168 18.06973
## 35    52    170 17.99308
## 36    57    160 22.26562
## 37    53    163 19.94806
## 38    55    168 19.48696
## 39    66    172 22.30936
## 4     55    174 18.16620
## 40    65    175 21.22449
## 41    75    180 23.14815
## 43    53    177 16.91723
## 44    55    169 19.25703
## 45    55    173 18.37683
## 46    72    182 21.73651
## 47    75    183 22.39541
## 48    73    184 21.56191
## 49    71    181 21.67211
## 5     50    168 17.71542
## 50    66    180 20.37037
## 51    71    178 22.40879
## 52    79    178 24.93372
## 53    62    168 21.96712
## 55    73    171 24.96495
## 56    72    180 22.22222
## 57    60    174 19.81768
## 58    67    175 21.87755
## 59    85    182 25.66115
## 60    73    181 22.28259
## 61    82    188 23.20054
## 62    86    182 25.96305
## 63    85    189 23.79553
## 64    65    178 20.51509
## 66    74    186 21.38976
## 8     72    189 20.15621
Quetelet_H=subset(Quetelet,subset=Quetelet$sexe=="h")
Quetelet_F=subset(Quetelet,subset=Quetelet$sexe=="f")

mvn(Quetelet_H[,-1], mvnTest = "mardia",
    univariateTest = "SW", univariatePlot = "histogram",
    multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = TRUE, showNewData = TRUE)

## $multivariateNormality
##              Test        Statistic              p value Result
## 1 Mardia Skewness 94.4778475662391 6.90120959921686e-16     NO
## 2 Mardia Kurtosis 8.12335586778857 4.44089209850063e-16     NO
## 3             MVN             <NA>                 <NA>     NO
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk   poids      0.9728    0.4238    YES   
## 2 Shapiro-Wilk  taille      0.9737    0.4511    YES   
## 3 Shapiro-Wilk    BMI       0.9776    0.5874    YES   
## 
## $Descriptives
##         n      Mean  Std.Dev    Median       Min       Max      25th
## poids  41  71.29268 7.619855  72.00000  55.00000  86.00000  66.00000
## taille 41 179.19512 6.738767 179.00000 164.00000 200.00000 175.00000
## BMI    41  22.18880 1.964237  21.96712  18.37683  26.76978  20.76125
##             75th       Skew   Kurtosis
## poids   75.00000 -0.1912013 -0.4367203
## taille 182.00000  0.3912155  0.8351991
## BMI     23.20054  0.3705053 -0.5164511
## 
## $multivariateOutliers
##    Observation Mahalanobis Distance Outlier
## 12          12              425.575    TRUE
## 63          63              118.562    TRUE
## 31          31              111.068    TRUE
## 44          44               69.381    TRUE
## 55          55               59.623    TRUE
## 61          61               56.435    TRUE
## 23          23               48.616    TRUE
## 62          62               42.313    TRUE
## 59          59               36.419    TRUE
## 45          45               31.723    TRUE
## 24          24               26.002    TRUE
## 8            8               19.838    TRUE
## 28          28               19.838    TRUE
## 14          14               11.973    TRUE
## 1            1               11.434    TRUE
## 
## $newData
##    poids taille      BMI
## 10    64    175 20.89796
## 13    61    175 19.91837
## 15    68    178 21.46194
## 18    79    179 24.65591
## 19    74    182 22.34030
## 20    62    174 20.47827
## 26    73    178 23.04002
## 27    70    180 21.60494
## 32    70    178 22.09317
## 33    76    178 23.98687
## 40    65    175 21.22449
## 41    75    180 23.14815
## 46    72    182 21.73651
## 47    75    183 22.39541
## 48    73    184 21.56191
## 49    71    181 21.67211
## 50    66    180 20.37037
## 51    71    178 22.40879
## 52    79    178 24.93372
## 53    62    168 21.96712
## 56    72    180 22.22222
## 57    60    174 19.81768
## 58    67    175 21.87755
## 60    73    181 22.28259
## 64    65    178 20.51509
## 66    74    186 21.38976
mvn(Quetelet_F[,-1], mvnTest = "mardia",
    univariateTest = "SW", univariatePlot = "histogram",
    multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = TRUE, showNewData = TRUE)

## $multivariateNormality
##              Test        Statistic              p value Result
## 1 Mardia Skewness 37.2056843384273 5.21388957554759e-05     NO
## 2 Mardia Kurtosis 2.48592654811622   0.0129214632354677     NO
## 3             MVN             <NA>                 <NA>     NO
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk   poids      0.8297    0.0007    NO    
## 2 Shapiro-Wilk  taille      0.9677    0.5864    YES   
## 3 Shapiro-Wilk    BMI       0.9471    0.2152    YES   
## 
## $Descriptives
##         n      Mean  Std.Dev   Median       Min       Max     25th
## poids  25  53.40000 5.545268  52.0000  47.00000  70.00000  50.0000
## taille 25 165.64000 6.350066 165.0000 150.00000 177.00000 161.0000
## BMI    25  19.46244 1.635013  19.4674  16.91723  23.66144  18.1662
##            75th       Skew    Kurtosis
## poids   55.0000  1.4874294  1.74551814
## taille 170.0000 -0.2756669 -0.48263809
## BMI     20.3125  0.7163074  0.01586493
## 
## $multivariateOutliers
##    Observation Mahalanobis Distance Outlier
## 29          29              547.900    TRUE
## 43          43              330.073    TRUE
## 39          39              255.928    TRUE
## 3            3              145.619    TRUE
## 30          30               61.975    TRUE
## 4            4               58.988    TRUE
## 35          35               48.558    TRUE
## 5            5               45.119    TRUE
## 34          34               30.206    TRUE
## 25          25               29.705    TRUE
## 
## $newData
##    poids taille      BMI
## 11    53    165 19.46740
## 16    51    158 20.42942
## 17    53    164 19.70553
## 2     57    169 19.95728
## 21    49    158 19.62826
## 22    50    163 18.81892
## 36    57    160 22.26562
## 37    53    163 19.94806
## 38    55    168 19.48696
## 42    50    162 19.05197
## 54    47    161 18.13202
## 6     50    161 19.28938
## 65    47    150 20.88889
## 7     48    162 18.28989
## 9     52    160 20.31250
cor(Quetelet[,-1], method="spearman")
##            poids    taille       BMI
## poids  1.0000000 0.8435359 0.8221544
## taille 0.8435359 1.0000000 0.4586364
## BMI    0.8221544 0.4586364 1.0000000
library(corrplot)
## corrplot 0.84 loaded
cor.mtest(Quetelet[,-1], method="spearman")
## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties
## $p
##              [,1]         [,2]         [,3]
## [1,] 0.000000e+00 6.173648e-19 2.625473e-17
## [2,] 6.173648e-19 0.000000e+00 1.075634e-04
## [3,] 2.625473e-17 1.075634e-04 0.000000e+00
## 
## $lowCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
## 
## $uppCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
#d'apres la formule du BMI, mauvais signe pour cor BMI et taille

library(ppcor)
## Loading required package: MASS
pcor(Quetelet[,-1], method = "spearman")
## $estimate
##            poids     taille        BMI
## poids  1.0000000  0.9221206  0.9120436
## taille 0.9221206  1.0000000 -0.7682441
## BMI    0.9120436 -0.7682441  1.0000000
## 
## $p.value
##               poids       taille          BMI
## poids  0.000000e+00 1.131073e-27 4.475042e-26
## taille 1.131073e-27 0.000000e+00 8.064386e-14
## BMI    4.475042e-26 8.064386e-14 0.000000e+00
## 
## $statistic
##           poids    taille       BMI
## poids   0.00000 18.917181 17.652378
## taille 18.91718  0.000000 -9.525396
## BMI    17.65238 -9.525396  0.000000
## 
## $n
## [1] 66
## 
## $gp
## [1] 1
## 
## $method
## [1] "spearman"
#d'apres la formule du BMI, bon signe pour cor BMI et taille


cor(Quetelet[,-1], method="kendall")
##            poids    taille       BMI
## poids  1.0000000 0.6806185 0.6495408
## taille 0.6806185 1.0000000 0.3060194
## BMI    0.6495408 0.3060194 1.0000000
cor.mtest(Quetelet[,-1], method="kendall")
## $p
##              [,1]         [,2]         [,3]
## [1,] 0.000000e+00 4.023325e-15 2.776287e-14
## [2,] 4.023325e-15 0.000000e+00 3.491883e-04
## [3,] 2.776287e-14 3.491883e-04 0.000000e+00
## 
## $lowCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
## 
## $uppCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
#d'apres la formule du BMI, mauvais signe pour cor BMI et taille
pcor(Quetelet[,-1], method = "kendall")
## $estimate
##            poids     taille        BMI
## poids  1.0000000  0.6656714  0.6326376
## taille 0.6656714  1.0000000 -0.2442715
## BMI    0.6326376 -0.2442715  1.0000000
## 
## $p.value
##               poids       taille          BMI
## poids  0.000000e+00 4.551113e-15 9.352566e-14
## taille 4.551113e-15 0.000000e+00 4.021582e-03
## BMI    9.352566e-14 4.021582e-03 0.000000e+00
## 
## $statistic
##           poids    taille       BMI
## poids  0.000000  7.838734  7.449738
## taille 7.838734  0.000000 -2.876464
## BMI    7.449738 -2.876464  0.000000
## 
## $n
## [1] 66
## 
## $gp
## [1] 1
## 
## $method
## [1] "kendall"
#d'apres la formule du BMI, bon signe pour cor BMI et taille


cor(Quetelet_H[,-1], method="spearman")
##            poids     taille        BMI
## poids  1.0000000 0.65435663 0.73250254
## taille 0.6543566 1.00000000 0.06367584
## BMI    0.7325025 0.06367584 1.00000000
cor.mtest(Quetelet_H[,-1], method="spearman")
## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties
## $p
##              [,1]         [,2]         [,3]
## [1,] 0.000000e+00 3.476465e-06 5.211433e-08
## [2,] 3.476465e-06 0.000000e+00 6.924613e-01
## [3,] 5.211433e-08 6.924613e-01 0.000000e+00
## 
## $lowCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
## 
## $uppCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
#d'apres la formule du BMI, mauvais signe pour cor BMI et taille
pcor(Quetelet_H[,-1], method = "spearman")
## $estimate
##            poids     taille        BMI
## poids  1.0000000  0.8945089  0.9154369
## taille 0.8945089  1.0000000 -0.8074098
## BMI    0.9154369 -0.8074098  1.0000000
## 
## $p.value
##               poids       taille          BMI
## poids  0.000000e+00 7.387085e-15 1.333566e-16
## taille 7.387085e-15 0.000000e+00 3.080328e-10
## BMI    1.333566e-16 3.080328e-10 0.000000e+00
## 
## $statistic
##           poids    taille       BMI
## poids   0.00000 12.334460 14.021543
## taille 12.33446  0.000000 -8.436075
## BMI    14.02154 -8.436075  0.000000
## 
## $n
## [1] 41
## 
## $gp
## [1] 1
## 
## $method
## [1] "spearman"
#d'apres la formule du BMI, bon signe pour cor BMI et taille


cor(Quetelet_H[,-1], method="kendall")
##            poids     taille        BMI
## poids  1.0000000 0.51311252 0.58853704
## taille 0.5131125 1.00000000 0.07154546
## BMI    0.5885370 0.07154546 1.00000000
cor.mtest(Quetelet_H[,-1], method="kendall")
## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties
## $p
##              [,1]         [,2]         [,3]
## [1,] 0.000000e+00 5.418566e-06 9.445912e-08
## [2,] 5.418566e-06 0.000000e+00 5.199700e-01
## [3,] 9.445912e-08 5.199700e-01 0.000000e+00
## 
## $lowCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
## 
## $uppCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
#d'apres la formule du BMI, mauvais signe pour cor BMI et taille
pcor(Quetelet_H[,-1], method = "kendall")
## $estimate
##            poids     taille        BMI
## poids  1.0000000  0.5840852  0.6445651
## taille 0.5840852  1.0000000 -0.3320813
## BMI    0.6445651 -0.3320813  1.0000000
## 
## $p.value
##               poids       taille          BMI
## poids  0.000000e+00 1.108022e-07 4.693702e-09
## taille 1.108022e-07 0.000000e+00 2.545407e-03
## BMI    4.693702e-09 2.545407e-03 0.000000e+00
## 
## $statistic
##           poids    taille       BMI
## poids  0.000000  5.308053  5.857683
## taille 5.308053  0.000000 -3.017891
## BMI    5.857683 -3.017891  0.000000
## 
## $n
## [1] 41
## 
## $gp
## [1] 1
## 
## $method
## [1] "kendall"
#d'apres la formule du BMI, bon signe pour cor BMI et taille


cor(Quetelet_F[,-1], method="spearman")
##            poids     taille        BMI
## poids  1.0000000  0.6248362  0.4366643
## taille 0.6248362  1.0000000 -0.2877543
## BMI    0.4366643 -0.2877543  1.0000000
cor.mtest(Quetelet_F[,-1], method="spearman")
## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties
## $p
##              [,1]         [,2]       [,3]
## [1,] 0.0000000000 0.0008402762 0.02907721
## [2,] 0.0008402762 0.0000000000 0.16307019
## [3,] 0.0290772141 0.1630701918 0.00000000
## 
## $lowCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
## 
## $uppCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
#d'apres la formule du BMI, mauvais signe pour cor BMI et taille
pcor(Quetelet_F[,-1], method = "spearman")
## $estimate
##            poids     taille        BMI
## poids  1.0000000  0.8710663  0.8244433
## taille 0.8710663  1.0000000 -0.7981326
## BMI    0.8244433 -0.7981326  1.0000000
## 
## $p.value
##               poids       taille          BMI
## poids  0.000000e+00 3.070201e-08 7.285921e-07
## taille 3.070201e-08 0.000000e+00 2.969505e-06
## BMI    7.285921e-07 2.969505e-06 0.000000e+00
## 
## $statistic
##           poids    taille       BMI
## poids  0.000000  8.318303  6.832793
## taille 8.318303  0.000000 -6.213587
## BMI    6.832793 -6.213587  0.000000
## 
## $n
## [1] 25
## 
## $gp
## [1] 1
## 
## $method
## [1] "spearman"
#d'apres la formule du BMI, bon signe pour cor BMI et taille


cor(Quetelet_F[,-1], method="kendall")
##            poids     taille        BMI
## poids  1.0000000  0.4823453  0.3226134
## taille 0.4823453  1.0000000 -0.2419674
## BMI    0.3226134 -0.2419674  1.0000000
cor.mtest(Quetelet_F[,-1], method="kendall")
## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties
## $p
##             [,1]        [,2]       [,3]
## [1,] 0.000000000 0.001294553 0.02839192
## [2,] 0.001294553 0.000000000 0.09596802
## [3,] 0.028391922 0.095968017 0.00000000
## 
## $lowCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
## 
## $uppCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
#d'apres la formule du BMI, mauvais signe pour cor BMI et taille
pcor(Quetelet_F[,-1], method = "kendall")
## $estimate
##            poids     taille        BMI
## poids  1.0000000  0.6101968  0.5168831
## taille 0.6101968  1.0000000 -0.4795052
## BMI    0.5168831 -0.4795052  1.0000000
## 
## $p.value
##               poids       taille          BMI
## poids  0.000000e+00 2.948386e-05 0.0004022705
## taille 2.948386e-05 0.000000e+00 0.0010281813
## BMI    4.022705e-04 1.028181e-03 0.0000000000
## 
## $statistic
##           poids    taille      BMI
## poids  0.000000  4.177417  3.53859
## taille 4.177417  0.000000 -3.28270
## BMI    3.538590 -3.282700  0.00000
## 
## $n
## [1] 25
## 
## $gp
## [1] 1
## 
## $method
## [1] "kendall"
#d'apres la formule du BMI, bon signe pour cor BMI et taille

library(GGally)
## Loading required package: ggplot2
ggpairs(Quetelet)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#Pour sauvegarder le graphique enlever les commentaires des trois commandes ci-dessous
# pdf("ggpairsBMI.pdf")
# print(ggpairs(Quetelet))
# dev.off()

#generation de donnees de type Ecole
library(mvtnorm)
sigma <- matrix(c(4,-.5,2.5,-.5,4,3,2.5,3,4),byrow=TRUE, ncol=3)
sigma
##      [,1] [,2] [,3]
## [1,]  4.0 -0.5  2.5
## [2,] -0.5  4.0  3.0
## [3,]  2.5  3.0  4.0
library(corpcor)
pcor2cor(cov2cor(sigma))
##           [,1]      [,2]      [,3]
## [1,] 1.0000000 0.6657503 0.8095238
## [2,] 0.6657503 1.0000000 0.8674928
## [3,] 0.8095238 0.8674928 1.0000000
aaa=rmvnorm(n=119, mean=c(11,11,14), sigma=pcor2cor(cov2cor(sigma)))
cor(aaa[,2],(aaa[,3]-5)/10)
## [1] 0.8875335
bbb=aaa
bbb[,3]<-(aaa[,3]-1)
bbb[,1]<-((aaa[,1])-7)/6*17
bbb[,2]<-((aaa[,2])-7)/6*17

round(aaa,digits = 2)
##         [,1]  [,2]  [,3]
##   [1,] 10.42 11.84 14.41
##   [2,]  9.97  9.91 12.94
##   [3,] 11.23 11.03 14.12
##   [4,] 10.68 10.15 13.05
##   [5,] 10.60 10.44 13.36
##   [6,] 12.73 11.80 14.47
##   [7,] 11.88 11.09 14.35
##   [8,] 11.50 11.04 14.20
##   [9,] 10.73 10.74 13.92
##  [10,] 11.68 10.70 14.37
##  [11,] 11.90 12.61 15.23
##  [12,] 10.35  9.84 13.04
##  [13,] 11.29 12.24 15.15
##  [14,] 11.80 11.42 14.83
##  [15,]  9.81  9.85 12.71
##  [16,] 11.34 11.14 13.84
##  [17,] 11.10 11.20 14.43
##  [18,] 11.13 10.49 13.92
##  [19,] 11.51 12.02 14.92
##  [20,] 10.83 11.41 14.68
##  [21,] 11.28 10.72 14.10
##  [22,] 11.08 10.31 13.92
##  [23,] 12.53 11.21 15.21
##  [24,] 10.08  9.87 12.79
##  [25,] 10.57 11.81 14.56
##  [26,] 10.97 11.21 14.51
##  [27,] 11.40 11.51 14.30
##  [28,] 11.66 11.24 14.09
##  [29,]  9.72  8.94 12.61
##  [30,] 10.61 10.96 14.32
##  [31,]  9.51 10.57 12.80
##  [32,]  9.37  8.75 11.26
##  [33,] 11.53 13.04 15.38
##  [34,] 10.17 10.60 13.82
##  [35,] 11.42 10.99 13.94
##  [36,] 10.45 10.99 13.58
##  [37,] 12.59 12.23 15.34
##  [38,] 10.03  9.88 12.91
##  [39,] 10.68 10.81 13.58
##  [40,] 10.30 10.33 13.15
##  [41,] 11.81 11.43 14.82
##  [42,]  9.90 11.26 14.19
##  [43,] 11.08 12.37 14.66
##  [44,] 12.07 12.46 15.63
##  [45,] 11.47 10.60 14.49
##  [46,] 11.47 10.86 14.43
##  [47,]  9.88 10.55 13.90
##  [48,]  9.70 10.97 14.58
##  [49,] 12.06 11.92 14.80
##  [50,] 11.19 12.09 13.99
##  [51,] 10.20 11.31 13.28
##  [52,] 10.14 10.66 13.57
##  [53,]  9.05  9.91 12.57
##  [54,] 11.11 11.65 14.89
##  [55,] 10.78 10.82 14.14
##  [56,] 12.22 11.94 15.22
##  [57,] 11.83  9.86 13.32
##  [58,] 11.92 10.86 14.28
##  [59,] 12.46 11.26 14.89
##  [60,] 10.26 10.71 14.25
##  [61,] 10.27 10.70 13.38
##  [62,] 12.10 12.44 15.30
##  [63,] 12.97 13.32 16.59
##  [64,] 13.43 12.53 15.79
##  [65,] 13.14 12.40 16.30
##  [66,] 13.16 12.86 16.23
##  [67,] 11.31 13.25 16.25
##  [68,] 11.45 12.06 14.94
##  [69,] 10.23 11.43 13.50
##  [70,] 12.10 11.25 14.89
##  [71,] 10.57 10.42 13.19
##  [72,] 11.43 11.23 14.21
##  [73,] 10.32 11.58 14.34
##  [74,]  9.99 11.46 14.09
##  [75,] 11.42 12.77 15.57
##  [76,]  9.18 10.44 12.85
##  [77,] 12.28 11.17 14.97
##  [78,] 10.30  9.67 12.61
##  [79,] 12.97 11.83 14.82
##  [80,] 11.93 12.05 15.01
##  [81,] 10.77 10.55 13.75
##  [82,]  9.88 10.71 13.61
##  [83,] 10.29 11.43 14.55
##  [84,]  8.84  9.65 11.74
##  [85,] 11.72 11.44 14.91
##  [86,] 12.40 12.77 15.25
##  [87,] 12.17 11.70 15.26
##  [88,] 11.09 11.90 14.47
##  [89,] 12.56 12.64 15.79
##  [90,] 10.99 11.15 14.36
##  [91,] 10.24  9.79 12.08
##  [92,] 11.26 11.61 14.73
##  [93,] 10.19 11.33 14.53
##  [94,] 11.27 11.47 14.75
##  [95,] 11.15 10.94 14.44
##  [96,] 10.50 11.10 13.90
##  [97,] 11.93 12.33 14.42
##  [98,] 10.53 12.36 14.30
##  [99,] 10.74 10.35 13.33
## [100,] 11.68 11.22 14.45
## [101,] 11.23 11.71 14.73
## [102,] 12.81 12.57 15.95
## [103,] 10.09  9.28 12.29
## [104,] 10.99 10.58 13.47
## [105,]  9.46 10.76 12.62
## [106,] 11.08 11.04 14.82
## [107,] 11.87 11.25 14.44
## [108,] 10.58 11.14 13.89
## [109,]  9.85 10.49 13.01
## [110,] 10.88 10.82 13.92
## [111,] 11.36 11.11 13.59
## [112,] 12.64 12.15 15.31
## [113,] 12.64 12.66 15.28
## [114,] 11.38 10.16 13.02
## [115,] 12.38 11.94 15.63
## [116,] 10.86 10.08 13.17
## [117,] 11.60 11.94 15.10
## [118,] 10.88 11.41 13.44
## [119,] 11.48 11.22 14.69
round(bbb,digits = 2)
##         [,1]  [,2]  [,3]
##   [1,]  9.68 13.70 13.41
##   [2,]  8.43  8.24 11.94
##   [3,] 11.99 11.41 13.12
##   [4,] 10.42  8.93 12.05
##   [5,] 10.20  9.75 12.36
##   [6,] 16.24 13.61 13.47
##   [7,] 13.82 11.60 13.35
##   [8,] 12.76 11.45 13.20
##   [9,] 10.56 10.61 12.92
##  [10,] 13.26 10.49 13.37
##  [11,] 13.88 15.89 14.23
##  [12,]  9.48  8.05 12.04
##  [13,] 12.14 14.86 14.15
##  [14,] 13.59 12.53 13.83
##  [15,]  7.97  8.08 11.71
##  [16,] 12.29 11.73 12.84
##  [17,] 11.63 11.90 13.43
##  [18,] 11.69  9.88 12.92
##  [19,] 12.77 14.22 13.92
##  [20,] 10.84 12.50 13.68
##  [21,] 12.13 10.54 13.10
##  [22,] 11.56  9.37 12.92
##  [23,] 15.66 11.92 14.21
##  [24,]  8.73  8.15 11.79
##  [25,] 10.11 13.64 13.56
##  [26,] 11.25 11.92 13.51
##  [27,] 12.46 12.78 13.30
##  [28,] 13.21 12.02 13.09
##  [29,]  7.70  5.51 11.61
##  [30,] 10.22 11.23 13.32
##  [31,]  7.12 10.13 11.80
##  [32,]  6.70  4.96 10.26
##  [33,] 12.84 17.10 14.38
##  [34,]  8.99 10.19 12.82
##  [35,] 12.52 11.30 12.94
##  [36,]  9.76 11.31 12.58
##  [37,] 15.83 14.82 14.34
##  [38,]  8.58  8.16 11.91
##  [39,] 10.44 10.80 12.58
##  [40,]  9.36  9.42 12.15
##  [41,] 13.62 12.54 13.82
##  [42,]  8.22 12.08 13.19
##  [43,] 11.57 15.21 13.66
##  [44,] 14.37 15.48 14.63
##  [45,] 12.68 10.19 13.49
##  [46,] 12.66 10.93 13.43
##  [47,]  8.15 10.07 12.90
##  [48,]  7.66 11.24 13.58
##  [49,] 14.35 13.94 13.80
##  [50,] 11.88 14.42 12.99
##  [51,]  9.07 12.21 12.28
##  [52,]  8.89 10.36 12.57
##  [53,]  5.81  8.25 11.57
##  [54,] 11.64 13.19 13.89
##  [55,] 10.71 10.83 13.14
##  [56,] 14.79 13.99 14.22
##  [57,] 13.69  8.10 12.32
##  [58,] 13.94 10.93 13.28
##  [59,] 15.46 12.08 13.89
##  [60,]  9.22 10.52 13.25
##  [61,]  9.27 10.47 12.38
##  [62,] 14.44 15.41 14.30
##  [63,] 16.92 17.91 15.59
##  [64,] 18.20 15.67 14.79
##  [65,] 17.40 15.31 15.30
##  [66,] 17.45 16.60 15.23
##  [67,] 12.21 17.71 15.25
##  [68,] 12.62 14.35 13.94
##  [69,]  9.15 12.55 12.50
##  [70,] 14.45 12.03 13.89
##  [71,] 10.13  9.69 12.19
##  [72,] 12.55 11.99 13.21
##  [73,]  9.41 12.97 13.34
##  [74,]  8.47 12.63 13.09
##  [75,] 12.51 16.34 14.57
##  [76,]  6.18  9.76 11.85
##  [77,] 14.97 11.83 13.97
##  [78,]  9.35  7.57 11.61
##  [79,] 16.90 13.69 13.82
##  [80,] 13.96 14.31 14.01
##  [81,] 10.68 10.07 12.75
##  [82,]  8.17 10.50 12.61
##  [83,]  9.32 12.54 13.55
##  [84,]  5.22  7.52 10.74
##  [85,] 13.38 12.57 13.91
##  [86,] 15.29 16.35 14.25
##  [87,] 14.66 13.30 14.26
##  [88,] 11.58 13.88 13.47
##  [89,] 15.75 15.99 14.79
##  [90,] 11.31 11.77 13.36
##  [91,]  9.19  7.89 11.08
##  [92,] 12.08 13.05 13.73
##  [93,]  9.05 12.28 13.53
##  [94,] 12.11 12.67 13.75
##  [95,] 11.76 11.15 13.44
##  [96,]  9.92 11.61 12.90
##  [97,] 13.97 15.09 13.42
##  [98,] 10.01 15.20 13.30
##  [99,] 10.59  9.49 12.33
## [100,] 13.25 11.96 13.45
## [101,] 11.98 13.34 13.73
## [102,] 16.47 15.78 14.95
## [103,]  8.76  6.45 11.29
## [104,] 11.32 10.15 12.47
## [105,]  6.96 10.64 11.62
## [106,] 11.57 11.45 13.82
## [107,] 13.81 12.03 13.44
## [108,] 10.16 11.73 12.89
## [109,]  8.06  9.88 12.01
## [110,] 11.00 10.82 12.92
## [111,] 12.35 11.66 12.59
## [112,] 15.97 14.60 14.31
## [113,] 15.97 16.04 14.28
## [114,] 12.40  8.95 12.02
## [115,] 15.25 14.00 14.63
## [116,] 10.94  8.71 12.17
## [117,] 13.02 13.98 14.10
## [118,] 11.00 12.49 12.44
## [119,] 12.69 11.96 13.69
boxplot(bbb)

colnames(bbb) <- c("Maths","Sport","Age")
bbb <- data.frame(bbb)

ccc <- round(bbb, 2)
ccc <- data.frame(ccc)
#Pour sauvegarder les jeux de donnees enlever les commentaires des deux commandes ci-dessous
# write.csv(ccc,file="Ecole3.csv",row.names = FALSE)
# write.csv(ccc[,1:2],file="Ecole2.csv",row.names = FALSE)

mvn(ccc, mvnTest = "mardia",
    univariateTest = "SW", univariatePlot = "histogram",
    multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = TRUE, showNewData = TRUE)

## $multivariateNormality
##              Test          Statistic           p value Result
## 1 Mardia Skewness   8.16781185199805 0.612449259212444    YES
## 2 Mardia Kurtosis -0.220229240847874 0.825692624711392    YES
## 3             MVN               <NA>              <NA>    YES
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk   Maths      0.9930    0.8131    YES   
## 2 Shapiro-Wilk   Sport      0.9925    0.7723    YES   
## 3 Shapiro-Wilk    Age       0.9911    0.6394    YES   
## 
## $Descriptives
##         n     Mean   Std.Dev Median   Min   Max   25th   75th        Skew
## Maths 119 11.68655 2.7476666  11.69  5.22 18.20  9.445 13.605  0.08565721
## Sport 119 11.92933 2.5767259  11.92  4.96 17.91 10.275 13.695 -0.03735769
## Age   119 13.21706 0.9928647  13.34 10.26 15.59 12.575 13.860 -0.24752051
##          Kurtosis
## Maths -0.49930432
## Sport -0.18100674
## Age    0.01724051
## 
## $multivariateOutliers
## [1] Observation          Mahalanobis Distance Outlier             
## <0 rows> (or 0-length row.names)
## 
## $newData
##     Maths Sport   Age
## 1    9.68 13.70 13.41
## 10  13.26 10.49 13.37
## 100 13.25 11.96 13.45
## 101 11.98 13.34 13.73
## 102 16.47 15.78 14.95
## 103  8.76  6.45 11.29
## 104 11.32 10.15 12.47
## 105  6.96 10.64 11.62
## 106 11.57 11.45 13.82
## 107 13.81 12.03 13.44
## 108 10.16 11.73 12.89
## 109  8.06  9.88 12.01
## 11  13.88 15.89 14.23
## 110 11.00 10.82 12.92
## 111 12.35 11.66 12.59
## 112 15.97 14.60 14.31
## 113 15.97 16.04 14.28
## 114 12.40  8.95 12.02
## 115 15.25 14.00 14.63
## 116 10.94  8.71 12.17
## 117 13.02 13.98 14.10
## 118 11.00 12.49 12.44
## 119 12.69 11.96 13.69
## 12   9.48  8.05 12.04
## 13  12.14 14.86 14.15
## 14  13.59 12.53 13.83
## 15   7.97  8.08 11.71
## 16  12.29 11.73 12.84
## 17  11.63 11.90 13.43
## 18  11.69  9.88 12.92
## 19  12.77 14.22 13.92
## 2    8.43  8.24 11.94
## 20  10.84 12.50 13.68
## 21  12.13 10.54 13.10
## 22  11.56  9.37 12.92
## 23  15.66 11.92 14.21
## 24   8.73  8.15 11.79
## 25  10.11 13.64 13.56
## 26  11.25 11.92 13.51
## 27  12.46 12.78 13.30
## 28  13.21 12.02 13.09
## 29   7.70  5.51 11.61
## 3   11.99 11.41 13.12
## 30  10.22 11.23 13.32
## 31   7.12 10.13 11.80
## 32   6.70  4.96 10.26
## 33  12.84 17.10 14.38
## 34   8.99 10.19 12.82
## 35  12.52 11.30 12.94
## 36   9.76 11.31 12.58
## 37  15.83 14.82 14.34
## 38   8.58  8.16 11.91
## 39  10.44 10.80 12.58
## 4   10.42  8.93 12.05
## 40   9.36  9.42 12.15
## 41  13.62 12.54 13.82
## 42   8.22 12.08 13.19
## 43  11.57 15.21 13.66
## 44  14.37 15.48 14.63
## 45  12.68 10.19 13.49
## 46  12.66 10.93 13.43
## 47   8.15 10.07 12.90
## 48   7.66 11.24 13.58
## 49  14.35 13.94 13.80
## 5   10.20  9.75 12.36
## 50  11.88 14.42 12.99
## 51   9.07 12.21 12.28
## 52   8.89 10.36 12.57
## 53   5.81  8.25 11.57
## 54  11.64 13.19 13.89
## 55  10.71 10.83 13.14
## 56  14.79 13.99 14.22
## 57  13.69  8.10 12.32
## 58  13.94 10.93 13.28
## 59  15.46 12.08 13.89
## 6   16.24 13.61 13.47
## 60   9.22 10.52 13.25
## 61   9.27 10.47 12.38
## 62  14.44 15.41 14.30
## 63  16.92 17.91 15.59
## 64  18.20 15.67 14.79
## 65  17.40 15.31 15.30
## 66  17.45 16.60 15.23
## 67  12.21 17.71 15.25
## 68  12.62 14.35 13.94
## 69   9.15 12.55 12.50
## 7   13.82 11.60 13.35
## 70  14.45 12.03 13.89
## 71  10.13  9.69 12.19
## 72  12.55 11.99 13.21
## 73   9.41 12.97 13.34
## 74   8.47 12.63 13.09
## 75  12.51 16.34 14.57
## 76   6.18  9.76 11.85
## 77  14.97 11.83 13.97
## 78   9.35  7.57 11.61
## 79  16.90 13.69 13.82
## 8   12.76 11.45 13.20
## 80  13.96 14.31 14.01
## 81  10.68 10.07 12.75
## 82   8.17 10.50 12.61
## 83   9.32 12.54 13.55
## 84   5.22  7.52 10.74
## 85  13.38 12.57 13.91
## 86  15.29 16.35 14.25
## 87  14.66 13.30 14.26
## 88  11.58 13.88 13.47
## 89  15.75 15.99 14.79
## 9   10.56 10.61 12.92
## 90  11.31 11.77 13.36
## 91   9.19  7.89 11.08
## 92  12.08 13.05 13.73
## 93   9.05 12.28 13.53
## 94  12.11 12.67 13.75
## 95  11.76 11.15 13.44
## 96   9.92 11.61 12.90
## 97  13.97 15.09 13.42
## 98  10.01 15.20 13.30
## 99  10.59  9.49 12.33
mvn(ccc[,1:2], mvnTest = "mardia",
    univariateTest = "SW", univariatePlot = "histogram",
    multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = TRUE, showNewData = TRUE)

## $multivariateNormality
##              Test         Statistic           p value Result
## 1 Mardia Skewness  1.09415871038731 0.895197881286257    YES
## 2 Mardia Kurtosis -1.13437875788271  0.25663570552363    YES
## 3             MVN              <NA>              <NA>    YES
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk   Maths      0.9930    0.8131    YES   
## 2 Shapiro-Wilk   Sport      0.9925    0.7723    YES   
## 
## $Descriptives
##         n     Mean  Std.Dev Median  Min   Max   25th   75th        Skew
## Maths 119 11.68655 2.747667  11.69 5.22 18.20  9.445 13.605  0.08565721
## Sport 119 11.92933 2.576726  11.92 4.96 17.91 10.275 13.695 -0.03735769
##         Kurtosis
## Maths -0.4993043
## Sport -0.1810067
## 
## $multivariateOutliers
## [1] Observation          Mahalanobis Distance Outlier             
## <0 rows> (or 0-length row.names)
## 
## $newData
##     Maths Sport
## 1    9.68 13.70
## 10  13.26 10.49
## 100 13.25 11.96
## 101 11.98 13.34
## 102 16.47 15.78
## 103  8.76  6.45
## 104 11.32 10.15
## 105  6.96 10.64
## 106 11.57 11.45
## 107 13.81 12.03
## 108 10.16 11.73
## 109  8.06  9.88
## 11  13.88 15.89
## 110 11.00 10.82
## 111 12.35 11.66
## 112 15.97 14.60
## 113 15.97 16.04
## 114 12.40  8.95
## 115 15.25 14.00
## 116 10.94  8.71
## 117 13.02 13.98
## 118 11.00 12.49
## 119 12.69 11.96
## 12   9.48  8.05
## 13  12.14 14.86
## 14  13.59 12.53
## 15   7.97  8.08
## 16  12.29 11.73
## 17  11.63 11.90
## 18  11.69  9.88
## 19  12.77 14.22
## 2    8.43  8.24
## 20  10.84 12.50
## 21  12.13 10.54
## 22  11.56  9.37
## 23  15.66 11.92
## 24   8.73  8.15
## 25  10.11 13.64
## 26  11.25 11.92
## 27  12.46 12.78
## 28  13.21 12.02
## 29   7.70  5.51
## 3   11.99 11.41
## 30  10.22 11.23
## 31   7.12 10.13
## 32   6.70  4.96
## 33  12.84 17.10
## 34   8.99 10.19
## 35  12.52 11.30
## 36   9.76 11.31
## 37  15.83 14.82
## 38   8.58  8.16
## 39  10.44 10.80
## 4   10.42  8.93
## 40   9.36  9.42
## 41  13.62 12.54
## 42   8.22 12.08
## 43  11.57 15.21
## 44  14.37 15.48
## 45  12.68 10.19
## 46  12.66 10.93
## 47   8.15 10.07
## 48   7.66 11.24
## 49  14.35 13.94
## 5   10.20  9.75
## 50  11.88 14.42
## 51   9.07 12.21
## 52   8.89 10.36
## 53   5.81  8.25
## 54  11.64 13.19
## 55  10.71 10.83
## 56  14.79 13.99
## 57  13.69  8.10
## 58  13.94 10.93
## 59  15.46 12.08
## 6   16.24 13.61
## 60   9.22 10.52
## 61   9.27 10.47
## 62  14.44 15.41
## 63  16.92 17.91
## 64  18.20 15.67
## 65  17.40 15.31
## 66  17.45 16.60
## 67  12.21 17.71
## 68  12.62 14.35
## 69   9.15 12.55
## 7   13.82 11.60
## 70  14.45 12.03
## 71  10.13  9.69
## 72  12.55 11.99
## 73   9.41 12.97
## 74   8.47 12.63
## 75  12.51 16.34
## 76   6.18  9.76
## 77  14.97 11.83
## 78   9.35  7.57
## 79  16.90 13.69
## 8   12.76 11.45
## 80  13.96 14.31
## 81  10.68 10.07
## 82   8.17 10.50
## 83   9.32 12.54
## 84   5.22  7.52
## 85  13.38 12.57
## 86  15.29 16.35
## 87  14.66 13.30
## 88  11.58 13.88
## 89  15.75 15.99
## 9   10.56 10.61
## 90  11.31 11.77
## 91   9.19  7.89
## 92  12.08 13.05
## 93   9.05 12.28
## 94  12.11 12.67
## 95  11.76 11.15
## 96   9.92 11.61
## 97  13.97 15.09
## 98  10.01 15.20
## 99  10.59  9.49
mvn(read.csv("https://tinyurl.com/y2c68uvw"), mvnTest = "mardia",
    univariateTest = "SW", univariatePlot = "histogram",
    multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = TRUE, showNewData = TRUE)

## $multivariateNormality
##              Test          Statistic           p value Result
## 1 Mardia Skewness   2.60917512706068 0.625198653395491    YES
## 2 Mardia Kurtosis -0.584809559089414 0.558675776111823    YES
## 3             MVN               <NA>              <NA>    YES
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk   Maths      0.9904    0.5745    YES   
## 2 Shapiro-Wilk   Sport      0.9949    0.9447    YES   
## 
## $Descriptives
##         n     Mean  Std.Dev Median  Min   Max  25th  75th       Skew
## Maths 119 11.56353 3.039590  11.66 3.54 19.95 9.715 13.19  0.1241263
## Sport 119 11.55899 2.962568  11.50 3.62 19.10 9.510 13.88 -0.1423103
##         Kurtosis
## Maths  0.1995491
## Sport -0.3439857
## 
## $multivariateOutliers
## [1] Observation          Mahalanobis Distance Outlier             
## <0 rows> (or 0-length row.names)
## 
## $newData
##     Maths Sport
## 1   13.12 14.44
## 10  13.86 10.76
## 100  8.60 10.57
## 101 10.81 11.37
## 102 15.34 11.84
## 103 12.18 12.26
## 104 11.40 13.31
## 105 12.21 10.92
## 106 10.31 10.95
## 107 11.06  5.82
## 108  8.03  5.72
## 109 15.61 17.34
## 11  15.57 14.58
## 110 11.01 11.00
## 111  7.92  8.70
## 112 14.04 11.20
## 113  6.64 10.32
## 114 10.28  8.43
## 115 10.52 14.37
## 116  8.91 10.55
## 117 14.98 15.75
## 118 10.21 10.94
## 119 11.78 10.18
## 12  19.43 17.05
## 13  14.76 13.35
## 14  10.03  7.27
## 15  13.74 15.60
## 16  12.01 11.16
## 17   9.06  9.59
## 18  10.26 14.21
## 19   6.86  9.01
## 2   12.43 14.32
## 20  11.41  9.10
## 21  11.96 13.93
## 22  10.19  6.61
## 23  10.19  9.75
## 24   7.83 11.11
## 25   9.63  9.24
## 26  10.67 12.61
## 27  13.10 12.67
## 28  11.99 11.50
## 29  15.23 14.41
## 3   16.26 15.85
## 30  19.42 19.10
## 31  13.29 12.00
## 32   8.85  8.42
## 33  13.34 12.15
## 34  11.61 11.76
## 35   8.72  8.17
## 36   9.03 12.82
## 37   7.27  8.69
## 38  10.82 12.64
## 39  15.25 16.28
## 4   12.61  7.68
## 40  10.78 12.83
## 41  11.60  9.68
## 42  12.43  9.93
## 43  10.60 11.30
## 44  11.98  7.43
## 45   9.78 12.03
## 46   9.88  8.70
## 47  15.15 11.93
## 48   7.54 10.71
## 49  11.30  7.42
## 5    3.54  6.12
## 50  12.20 12.90
## 51  12.88 12.47
## 52  14.99 15.75
## 53  12.25 13.83
## 54  11.79 11.33
## 55  11.66 12.33
## 56  12.17 13.50
## 57   8.61  9.77
## 58   4.70  8.02
## 59   5.99  3.62
## 6   11.50 13.08
## 60  12.26 10.35
## 61  12.01 12.87
## 62  12.89 10.76
## 63  10.34  9.34
## 64   5.48  6.90
## 65  11.99 14.00
## 66   8.93 10.80
## 67  15.30 13.46
## 68   8.04 10.32
## 69  16.82 16.21
## 7    6.43  5.71
## 70  12.63  9.43
## 71  12.87 11.87
## 72  12.64 11.50
## 73   6.32  6.74
## 74   9.03  5.18
## 75  17.12 15.43
## 76   7.84  8.64
## 77  11.18 11.90
## 78  13.56 16.16
## 79  13.00 14.25
## 8   15.79 12.91
## 80  10.90  9.90
## 81  16.33 14.32
## 82   6.83  9.09
## 83  11.81 10.88
## 84  15.98 14.01
## 85  13.38  8.91
## 86   9.65 15.28
## 87  10.54 13.41
## 88  11.38 12.39
## 89  12.37  9.19
## 9    8.02 14.32
## 90  11.38 14.09
## 91  12.29 14.93
## 92  13.26  8.13
## 93  14.65 16.29
## 94  15.52 13.06
## 95  19.95 15.08
## 96  14.76 16.23
## 97   8.95 12.39
## 98   8.64 10.85
## 99  12.04 13.99
mvn(read.csv("https://tinyurl.com/y2asrzgk"), mvnTest = "mardia",
    univariateTest = "SW", univariatePlot = "histogram",
    multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = TRUE, showNewData = TRUE)

## $multivariateNormality
##              Test          Statistic           p value Result
## 1 Mardia Skewness   12.9057396369826  0.22898988609509    YES
## 2 Mardia Kurtosis -0.574084544554668 0.565910591483027    YES
## 3             MVN               <NA>              <NA>    YES
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk   Maths      0.9904    0.5745    YES   
## 2 Shapiro-Wilk   Sport      0.9949    0.9447    YES   
## 3 Shapiro-Wilk    Age       0.9855    0.2327    YES   
## 
## $Descriptives
##         n     Mean  Std.Dev Median   Min   Max   25th   75th       Skew
## Maths 119 11.56353 3.039590  11.66  3.54 19.95  9.715 13.190  0.1241263
## Sport 119 11.55899 2.962568  11.50  3.62 19.10  9.510 13.880 -0.1423103
## Age   119 13.07538 1.014806  12.99 10.77 15.44 12.355 13.705  0.2857010
##         Kurtosis
## Maths  0.1995491
## Sport -0.3439857
## Age   -0.2784684
## 
## $multivariateOutliers
## [1] Observation          Mahalanobis Distance Outlier             
## <0 rows> (or 0-length row.names)
## 
## $newData
##     Maths Sport   Age
## 1   13.12 14.44 13.40
## 10  13.86 10.76 12.92
## 100  8.60 10.57 12.07
## 101 10.81 11.37 12.98
## 102 15.34 11.84 13.89
## 103 12.18 12.26 13.51
## 104 11.40 13.31 13.00
## 105 12.21 10.92 12.91
## 106 10.31 10.95 12.96
## 107 11.06  5.82 12.18
## 108  8.03  5.72 12.02
## 109 15.61 17.34 15.44
## 11  15.57 14.58 14.83
## 110 11.01 11.00 12.50
## 111  7.92  8.70 12.31
## 112 14.04 11.20 13.79
## 113  6.64 10.32 13.09
## 114 10.28  8.43 12.63
## 115 10.52 14.37 13.84
## 116  8.91 10.55 12.40
## 117 14.98 15.75 14.14
## 118 10.21 10.94 12.29
## 119 11.78 10.18 12.68
## 12  19.43 17.05 15.24
## 13  14.76 13.35 13.66
## 14  10.03  7.27 11.63
## 15  13.74 15.60 14.37
## 16  12.01 11.16 12.48
## 17   9.06  9.59 11.89
## 18  10.26 14.21 12.58
## 19   6.86  9.01 12.67
## 2   12.43 14.32 14.44
## 20  11.41  9.10 11.72
## 21  11.96 13.93 13.47
## 22  10.19  6.61 11.91
## 23  10.19  9.75 12.65
## 24   7.83 11.11 12.78
## 25   9.63  9.24 12.45
## 26  10.67 12.61 12.88
## 27  13.10 12.67 13.44
## 28  11.99 11.50 12.70
## 29  15.23 14.41 14.35
## 3   16.26 15.85 14.17
## 30  19.42 19.10 15.38
## 31  13.29 12.00 12.96
## 32   8.85  8.42 11.93
## 33  13.34 12.15 13.84
## 34  11.61 11.76 12.99
## 35   8.72  8.17 10.77
## 36   9.03 12.82 12.86
## 37   7.27  8.69 11.60
## 38  10.82 12.64 13.25
## 39  15.25 16.28 14.15
## 4   12.61  7.68 12.76
## 40  10.78 12.83 12.15
## 41  11.60  9.68 13.25
## 42  12.43  9.93 12.73
## 43  10.60 11.30 12.68
## 44  11.98  7.43 12.23
## 45   9.78 12.03 12.92
## 46   9.88  8.70 11.43
## 47  15.15 11.93 13.26
## 48   7.54 10.71 12.55
## 49  11.30  7.42 12.25
## 5    3.54  6.12 11.29
## 50  12.20 12.90 13.35
## 51  12.88 12.47 13.20
## 52  14.99 15.75 15.08
## 53  12.25 13.83 13.60
## 54  11.79 11.33 13.58
## 55  11.66 12.33 12.40
## 56  12.17 13.50 13.18
## 57   8.61  9.77 11.71
## 58   4.70  8.02 11.84
## 59   5.99  3.62 10.89
## 6   11.50 13.08 13.38
## 60  12.26 10.35 13.29
## 61  12.01 12.87 13.19
## 62  12.89 10.76 13.18
## 63  10.34  9.34 12.45
## 64   5.48  6.90 11.59
## 65  11.99 14.00 13.83
## 66   8.93 10.80 12.24
## 67  15.30 13.46 13.47
## 68   8.04 10.32 12.27
## 69  16.82 16.21 15.31
## 7    6.43  5.71 11.53
## 70  12.63  9.43 12.65
## 71  12.87 11.87 12.83
## 72  12.64 11.50 13.13
## 73   6.32  6.74 11.33
## 74   9.03  5.18 11.64
## 75  17.12 15.43 14.51
## 76   7.84  8.64 12.31
## 77  11.18 11.90 12.24
## 78  13.56 16.16 14.57
## 79  13.00 14.25 14.17
## 8   15.79 12.91 13.77
## 80  10.90  9.90 12.18
## 81  16.33 14.32 13.88
## 82   6.83  9.09 12.21
## 83  11.81 10.88 13.11
## 84  15.98 14.01 14.16
## 85  13.38  8.91 13.37
## 86   9.65 15.28 13.63
## 87  10.54 13.41 13.91
## 88  11.38 12.39 13.32
## 89  12.37  9.19 13.12
## 9    8.02 14.32 13.54
## 90  11.38 14.09 14.10
## 91  12.29 14.93 13.75
## 92  13.26  8.13 12.40
## 93  14.65 16.29 14.28
## 94  15.52 13.06 15.08
## 95  19.95 15.08 15.15
## 96  14.76 16.23 15.15
## 97   8.95 12.39 13.26
## 98   8.64 10.85 12.54
## 99  12.04 13.99 13.63
cor(ccc)
##           Maths     Sport       Age
## Maths 1.0000000 0.6706710 0.7958409
## Sport 0.6706710 1.0000000 0.8874844
## Age   0.7958409 0.8874844 1.0000000
cor.mtest(ccc)
## $p
##              [,1]         [,2]         [,3]
## [1,] 0.000000e+00 7.186614e-17 2.963818e-27
## [2,] 7.186614e-17 0.000000e+00 3.571910e-41
## [3,] 2.963818e-27 3.571910e-41 0.000000e+00
## 
## $lowCI
##           [,1]      [,2]      [,3]
## [1,] 1.0000000 0.5580410 0.7188138
## [2,] 0.5580410 1.0000000 0.8419913
## [3,] 0.7188138 0.8419913 1.0000000
## 
## $uppCI
##           [,1]      [,2]      [,3]
## [1,] 1.0000000 0.7590373 0.8535651
## [2,] 0.7590373 1.0000000 0.9204451
## [3,] 0.8535651 0.9204451 1.0000000
pcor(ccc)
## $estimate
##            Maths      Sport       Age
## Maths  1.0000000 -0.1276710 0.5869337
## Sport -0.1276710  1.0000000 0.7875928
## Age    0.5869337  0.7875928 1.0000000
## 
## $p.value
##              Maths        Sport          Age
## Maths 0.000000e+00 1.682823e-01 2.850986e-12
## Sport 1.682823e-01 0.000000e+00 3.781357e-26
## Age   2.850986e-12 3.781357e-26 0.000000e+00
## 
## $statistic
##           Maths     Sport       Age
## Maths  0.000000 -1.386405  7.807802
## Sport -1.386405  0.000000 13.766126
## Age    7.807802 13.766126  0.000000
## 
## $n
## [1] 119
## 
## $gp
## [1] 1
## 
## $method
## [1] "pearson"
ggpairs(ccc)
res1=residuals(lm(Maths~Age,data=ccc))
res2=residuals(lm(Sport~Age,data=ccc))
plot(res1,res2)

cor(ccc, method="spearman")
##           Maths     Sport       Age
## Maths 1.0000000 0.6527990 0.7832539
## Sport 0.6527990 1.0000000 0.8678691
## Age   0.7832539 0.8678691 1.0000000
cor.mtest(ccc, method="spearman")
## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties

## Warning in cor.test.default(x = mat[, i], y = mat[, j], ...): Cannot
## compute exact p-value with ties
## $p
##              [,1]         [,2]         [,3]
## [1,] 0.000000e+00 8.653942e-16 6.604889e-26
## [2,] 8.653942e-16 0.000000e+00 2.397734e-37
## [3,] 6.604889e-26 2.397734e-37 0.000000e+00
## 
## $lowCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
## 
## $uppCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
pcor(ccc, method = "spearman")
## $estimate
##             Maths       Sport       Age
## Maths  1.00000000 -0.08729888 0.5758412
## Sport -0.08729888  1.00000000 0.7570978
## Age    0.57584119  0.75709782 1.0000000
## 
## $p.value
##              Maths        Sport          Age
## Maths 0.000000e+00 3.472125e-01 8.989092e-12
## Sport 3.472125e-01 0.000000e+00 3.468246e-23
## Age   8.989092e-12 3.468246e-23 0.000000e+00
## 
## $statistic
##            Maths      Sport       Age
## Maths  0.0000000 -0.9438412  7.585972
## Sport -0.9438412  0.0000000 12.481515
## Age    7.5859723 12.4815155  0.000000
## 
## $n
## [1] 119
## 
## $gp
## [1] 1
## 
## $method
## [1] "spearman"
cor(ccc, method="kendall")
##           Maths     Sport       Age
## Maths 1.0000000 0.4712005 0.5994584
## Sport 0.4712005 1.0000000 0.6994577
## Age   0.5994584 0.6994577 1.0000000
cor.mtest(ccc, method="kendall")
## $p
##              [,1]         [,2]         [,3]
## [1,] 0.000000e+00 3.171405e-14 4.938679e-22
## [2,] 3.171405e-14 0.000000e+00 2.237647e-29
## [3,] 4.938679e-22 2.237647e-29 0.000000e+00
## 
## $lowCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
## 
## $uppCI
##      [,1] [,2] [,3]
## [1,]    1   NA   NA
## [2,]   NA    1   NA
## [3,]   NA   NA    1
pcor(ccc, method = "kendall")
## $estimate
##            Maths      Sport       Age
## Maths 1.00000000 0.09073793 0.4281253
## Sport 0.09073793 1.00000000 0.5906587
## Age   0.42812527 0.59065871 1.0000000
## 
## $p.value
##              Maths        Sport          Age
## Maths 0.000000e+00 1.451525e-01 6.247467e-12
## Sport 1.451525e-01 0.000000e+00 2.459129e-21
## Age   6.247467e-12 2.459129e-21 0.000000e+00
## 
## $statistic
##          Maths    Sport      Age
## Maths 0.000000 1.456869 6.873889
## Sport 1.456869 0.000000 9.483492
## Age   6.873889 9.483492 0.000000
## 
## $n
## [1] 119
## 
## $gp
## [1] 1
## 
## $method
## [1] "kendall"
ggpairs(ccc)