1. Importer les données

don <- read.table("https://r-stat-sc-donnees.github.io/poulpe.csv",header=TRUE,sep=";")
summary(don)
     Poids           Sexe   
 Min.   : 300   Femelle:13  
 1st Qu.:1480   Male   :15  
 Median :1800               
 Mean   :2099               
 3rd Qu.:2750               
 Max.   :5400               

2. Comparer graphiquement les deux sous-populations

boxplot(Poids ~ Sexe, ylab="Poids", xlab="Sexe", data=don)

require(ggplot2)
ggplot(don)+aes(x=Sexe,y=Poids)+geom_boxplot()

3. Estimer les statistiques de base dans chaque groupe

aggregate(don$Poids,by=list(don$Sexe),FUN=summary)
  Group.1   x.Min. x.1st Qu. x.Median   x.Mean x.3rd Qu.   x.Max.
1 Femelle  300.000   900.000 1500.000 1405.385  1800.000 2400.000
2    Male 1150.000  1800.000 2700.000 2700.000  3300.000 5400.000
tapply(don$Poids,don$Sexe,sd,na.rm=TRUE)
  Femelle      Male 
 621.9943 1158.3547 

4. Tester la normalité des données

select.males <- don[,"Sexe"]=="Male"
shapiro.test(don[select.males,"Poids"])

    Shapiro-Wilk normality test

data:  don[select.males, "Poids"]
W = 0.93501, p-value = 0.3238

5. Tester l’égalité des variances

var.test(Poids ~ Sexe,conf.level=.95,data=don)

    F test to compare two variances

data:  Poids by Sexe
F = 0.28833, num df = 12, denom df = 14, p-value = 0.03713
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
 0.09452959 0.92444666
sample estimates:
ratio of variances 
         0.2883299 

6. Tester l’égalité des moyennes

t.test(Poids~Sexe, alternative="two.sided", conf.level=.95,
       var.equal=FALSE, data=don)

    Welch Two Sample t-test

data:  Poids by Sexe
t = -3.7496, df = 22.021, p-value = 0.001107
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -2010.624  -578.607
sample estimates:
mean in group Femelle    mean in group Male 
             1405.385              2700.000 
t.test(Poids~Sexe, alternative="greater", conf.level=.95,
       var.equal=FALSE, data=don)

    Welch Two Sample t-test

data:  Poids by Sexe
t = -3.7496, df = 22.021, p-value = 0.9994
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
 -1887.471       Inf
sample estimates:
mean in group Femelle    mean in group Male 
             1405.385              2700.000 

Pour aller plus loin

power.t.test(delta = 1, sd = 3, sig.level = 0.05, power = 0.8)

     Two-sample t test power calculation 

              n = 142.2466
          delta = 1
             sd = 3
      sig.level = 0.05
          power = 0.8
    alternative = two.sided

NOTE: n is number in *each* group
power.t.test(n = 100, delta = 1, sd = 3, sig.level = 0.05)

     Two-sample t test power calculation 

              n = 100
          delta = 1
             sd = 3
      sig.level = 0.05
          power = 0.6501087
    alternative = two.sided

NOTE: n is number in *each* group
LS0tDQp0aXRsZTogIkNvbXBhcmFpc29uIGRlIGRldXggbW95ZW5uZXMiDQphdXRob3I6ICJIdXNzb24gZXQgYWwuIg0KZGF0ZTogIjA1LzA5LzIwMTgiDQpvdXRwdXQ6DQogIGh0bWxfbm90ZWJvb2s6DQogICAgdG9jOiB5ZXMNCiAgICB0b2NfZGVwdGg6IDMNCiAgICB0b2NfZmxvYXQ6IHllcw0KICBodG1sX2RvY3VtZW50Og0KICAgIHRvYzogeWVzDQogICAgdG9jX2RlcHRoOiAnMycNCiAgICB0b2NfZmxvYXQ6IHllcw0KLS0tDQoNCiMgMS4gSW1wb3J0ZXIgbGVzIGRvbm7DqWVzDQoNCmBgYHtyfQ0KZG9uIDwtIHJlYWQudGFibGUoImh0dHBzOi8vci1zdGF0LXNjLWRvbm5lZXMuZ2l0aHViLmlvL3BvdWxwZS5jc3YiLGhlYWRlcj1UUlVFLHNlcD0iOyIpDQpzdW1tYXJ5KGRvbikNCmBgYA0KDQojIDIuIENvbXBhcmVyIGdyYXBoaXF1ZW1lbnQgbGVzIGRldXggc291cy1wb3B1bGF0aW9ucw0KDQpgYGB7cixmaWcud2lkdGg9NCxmaWcuaGVpZ2h0PTR9DQpib3hwbG90KFBvaWRzIH4gU2V4ZSwgeWxhYj0iUG9pZHMiLCB4bGFiPSJTZXhlIiwgZGF0YT1kb24pDQpgYGANCg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