1. Importer les données

ozone <- read.table("https://r-stat-sc-donnees.github.io/ozone.txt",header=TRUE)
ozone.m <- ozone[,1:11]
summary(ozone.m)
     maxO3              T9             T12             T15             Ne9             Ne12            Ne15     
 Min.   : 42.00   Min.   :11.30   Min.   :14.00   Min.   :14.90   Min.   :0.000   Min.   :0.000   Min.   :0.00  
 1st Qu.: 70.75   1st Qu.:16.20   1st Qu.:18.60   1st Qu.:19.27   1st Qu.:3.000   1st Qu.:4.000   1st Qu.:3.00  
 Median : 81.50   Median :17.80   Median :20.55   Median :22.05   Median :6.000   Median :5.000   Median :5.00  
 Mean   : 90.30   Mean   :18.36   Mean   :21.53   Mean   :22.63   Mean   :4.929   Mean   :5.018   Mean   :4.83  
 3rd Qu.:106.00   3rd Qu.:19.93   3rd Qu.:23.55   3rd Qu.:25.40   3rd Qu.:7.000   3rd Qu.:7.000   3rd Qu.:7.00  
 Max.   :166.00   Max.   :27.00   Max.   :33.50   Max.   :35.50   Max.   :8.000   Max.   :8.000   Max.   :8.00  
      Vx9               Vx12             Vx15            maxO3v      
 Min.   :-7.8785   Min.   :-7.878   Min.   :-9.000   Min.   : 42.00  
 1st Qu.:-3.2765   1st Qu.:-3.565   1st Qu.:-3.939   1st Qu.: 71.00  
 Median :-0.8660   Median :-1.879   Median :-1.550   Median : 82.50  
 Mean   :-1.2143   Mean   :-1.611   Mean   :-1.691   Mean   : 90.57  
 3rd Qu.: 0.6946   3rd Qu.: 0.000   3rd Qu.: 0.000   3rd Qu.:106.00  
 Max.   : 5.1962   Max.   : 6.578   Max.   : 5.000   Max.   :166.00  

2. Représenter les variables

pairs(ozone.m[,1:4])

3. Estimer les paramètres

reg.mul <- lm(maxO3~., data=ozone.m)
summary(reg.mul)

Call:
lm(formula = maxO3 ~ ., data = ozone.m)

Residuals:
    Min      1Q  Median      3Q     Max 
-53.566  -8.727  -0.403   7.599  39.458 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 12.24442   13.47190   0.909   0.3656    
T9          -0.01901    1.12515  -0.017   0.9866    
T12          2.22115    1.43294   1.550   0.1243    
T15          0.55853    1.14464   0.488   0.6266    
Ne9         -2.18909    0.93824  -2.333   0.0216 *  
Ne12        -0.42102    1.36766  -0.308   0.7588    
Ne15         0.18373    1.00279   0.183   0.8550    
Vx9          0.94791    0.91228   1.039   0.3013    
Vx12         0.03120    1.05523   0.030   0.9765    
Vx15         0.41859    0.91568   0.457   0.6486    
maxO3v       0.35198    0.06289   5.597 1.88e-07 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 14.36 on 101 degrees of freedom
Multiple R-squared:  0.7638,    Adjusted R-squared:  0.7405 
F-statistic: 32.67 on 10 and 101 DF,  p-value: < 2.2e-16

4. Choix de variables

 library(leaps)
 choix <- regsubsets(maxO3~.,data=ozone.m,nbest=1,nvmax=11)
 plot(choix,scale="bic")

reg.fin <- lm(maxO3~T12+Ne9+Vx9+maxO3v,data=ozone.m)
summary(reg.fin)

Call:
lm(formula = maxO3 ~ T12 + Ne9 + Vx9 + maxO3v, data = ozone.m)

Residuals:
    Min      1Q  Median      3Q     Max 
-52.396  -8.377  -1.086   7.951  40.933 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 12.63131   11.00088   1.148 0.253443    
T12          2.76409    0.47450   5.825 6.07e-08 ***
Ne9         -2.51540    0.67585  -3.722 0.000317 ***
Vx9          1.29286    0.60218   2.147 0.034055 *  
maxO3v       0.35483    0.05789   6.130 1.50e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 14 on 107 degrees of freedom
Multiple R-squared:  0.7622,    Adjusted R-squared:  0.7533 
F-statistic: 85.75 on 4 and 107 DF,  p-value: < 2.2e-16

5. Analyser les résidus

res.m <- rstudent(reg.fin)
plot(res.m,pch=15,cex=.5,ylab="Résidus",main="",ylim=c(-3,3))
abline(h=c(-2,0,2),lty=c(2,1,2))

6. Prévoir une nouvelle valeur

xnew <- matrix(c(19,8,2.05,70),nrow=1)
colnames(xnew) <- c("T12","Ne9","Vx9","maxO3v")
xnew <- as.data.frame(xnew)
predict(reg.fin,xnew,interval="pred")
       fit      lwr      upr
1 72.51437 43.80638 101.2224
LS0tDQp0aXRsZTogIlLDqWdyZXNzaW9uIG11bHRpcGxlIg0KYXV0aG9yOiAiSHVzc29uIGV0IGFsLiINCmRhdGU6ICIxMiBzZXB0ZW1icmUgMjAxOCINCm91dHB1dDoNCiAgaHRtbF9ub3RlYm9vazoNCiAgICB0b2M6IHllcw0KICAgIHRvY19kZXB0aDogMw0KICAgIHRvY19mbG9hdDogeWVzDQogIGh0bWxfZG9jdW1lbnQ6DQogICAgdG9jOiB5ZXMNCiAgICB0b2NfZGVwdGg6ICczJw0KICAgIHRvY19mbG9hdDogeWVzDQotLS0NCg0KYGBge3Igc2V0dXAsIGluY2x1ZGU9RkFMU0V9DQprbml0cjo6b3B0c19jaHVuayRzZXQoZWNobyA9IFRSVUUpDQpgYGANCg0KIyAxLiBJbXBvcnRlciBsZXMgZG9ubsOpZXMNCg0KYGBge3Igb3pvbmV9DQpvem9uZSA8LSByZWFkLnRhYmxlKCJodHRwczovL3Itc3RhdC1zYy1kb25uZWVzLmdpdGh1Yi5pby9vem9uZS50eHQiLGhlYWRlcj1UUlVFKQ0Kb3pvbmUubSA8LSBvem9uZVssMToxMV0NCnN1bW1hcnkob3pvbmUubSkNCmBgYA0KDQojIDIuIFJlcHLDqXNlbnRlciBsZXMgdmFyaWFibGVzDQpgYGB7cn0NCnBhaXJzKG96b25lLm1bLDE6NF0pDQpgYGANCg0KIyAzLiBFc3RpbWVyIGxlcyBwYXJhbcOodHJlcw0KDQpgYGB7cn0NCnJlZy5tdWwgPC0gbG0obWF4TzN+LiwgZGF0YT1vem9uZS5tKQ0Kc3VtbWFyeShyZWcubXVsKQ0KYGBgDQoNCiMgNC4gQ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