1. Importer les données
ozone <- read.table("https://r-stat-sc-donnees.github.io/ozone.txt",header=T)
summary(ozone[,c("maxO3","vent","pluie")])
maxO3 vent pluie
Min. : 42.00 Est :10 Pluie:43
1st Qu.: 70.75 Nord :31 Sec :69
Median : 81.50 Ouest:50
Mean : 90.30 Sud :21
3rd Qu.:106.00
Max. :166.00
2. Représenter les données
boxplot(maxO3~vent*pluie, data = ozone,
col=c(rep("Lightblue",4),rep("orange",4)))
par(mfrow=c(1,2))
with(ozone,interaction.plot(vent,pluie,maxO3,col=1:nlevels(pluie)))
with(ozone,interaction.plot(pluie,vent,maxO3,col=1:nlevels(vent)))
3. Choisir le modèle
table(ozone$pluie, ozone$vent)
Est Nord Ouest Sud
Pluie 2 10 26 5
Sec 8 21 24 16
library(FactoMineR)
mod.interaction <- AovSum(maxO3~vent+pluie+vent:pluie,data=ozone)
mod.interaction$Ftest
SS df MS F value Pr(>F)
vent 3227 3 1075.6 1.7633 0.1588
pluie 10996 1 10996.5 18.0271 4.749e-05 ***
vent:pluie 1006 3 335.5 0.5500 0.6493
Residuals 63440 104 610.0
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
modele.sans.int <- AovSum(maxO3~vent+pluie,data=ozone)
modele.sans.int$Ftest
SS df MS F value Pr(>F)
vent 3791 3 1263.8 2.0982 0.1048
pluie 16159 1 16159.4 26.8295 1.052e-06 ***
Residuals 64446 107 602.3
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
modele.anova.simple <- AovSum(maxO3~pluie,data=ozone)
modele.anova.simple$Ftest
SS df MS F value Pr(>F)
pluie 19954 1 19954.2 32.166 1.157e-07 ***
Residuals 68238 110 620.3
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
4. Estimer et interpréter les coefficients
modele.anova.simple$Ttest
Estimate Std. Error t value Pr(>|t|)
(Intercept) 87.11796 2.419555 36.005777 1.066479e-62
pluie - Pluie -13.72262 2.419555 -5.671545 1.156980e-07
pluie - Sec 13.72262 2.419555 5.671545 1.156980e-07
Pour aller plus loin
mod1 <- lm(maxO3~pluie,data=ozone)
anova(mod1)
Analysis of Variance Table
Response: maxO3
Df Sum Sq Mean Sq F value Pr(>F)
pluie 1 19954 19954.2 32.166 1.157e-07 ***
Residuals 110 68238 620.3
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(mod1)$coef
Estimate Std. Error t value Pr(>|t|)
(Intercept) 73.39535 3.798228 19.323575 3.757447e-37
pluieSec 27.44523 4.839110 5.671545 1.156980e-07
LS0tDQp0aXRsZTogIkFuYWx5c2UgZGUgdmFyaWFuY2UiDQphdXRob3I6ICJIdXNzb24gZXQgYWwuIg0KZGF0ZTogIjA1LzA5LzIwMTgiDQpvdXRwdXQ6DQogIGh0bWxfbm90ZWJvb2s6DQogICAgdG9jOiB5ZXMNCiAgICB0b2NfZGVwdGg6IDMNCiAgICB0b2NfZmxvYXQ6IHllcw0KICBodG1sX2RvY3VtZW50Og0KICAgIHRvYzogeWVzDQogICAgdG9jX2RlcHRoOiAnMycNCiAgICB0b2NfZmxvYXQ6IHllcw0KLS0tDQoNCg0KYGBge3Igc2V0dXAsIGluY2x1ZGU9RkFMU0V9DQprbml0cjo6b3B0c19jaHVuayRzZXQoZWNobyA9IFRSVUUpDQpgYGANCg0KIyAxLiBJbXBvcnRlciBsZXMgZG9ubsOpZXMNCg0KYGBge3Igb3pvbmV9DQpvem9uZSA8LSByZWFkLnRhYmxlKCJodHRwczovL3Itc3RhdC1zYy1kb25uZWVzLmdpdGh1Yi5pby9vem9uZS50eHQiLGhlYWRlcj1UKQ0Kc3VtbWFyeShvem9uZVssYygibWF4TzMiLCJ2ZW50IiwicGx1aWUiKV0pDQpgYGANCg0KIyAyLiBSZXByw6lzZ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