7 Choix de variables

ozone <- read.table("../donnees/ozone.txt", header = T, sep = ";")
library(leaps)
recherche <- regsubsets(O3 ~ T12 + T15 + Ne12 + N12 + S12 + E12 + W12 + Vx + O3v, int = T,nbest = 1, nvmax = 10, method = "exhaustive", data = ozone)
plot(recherche, scale = "bic")

plot(recherche, scale = "Cp")

plot(recherche, scale = "adjr2")

plot(recherche, scale = "r2")

resume <- summary(recherche)
nomselec <- colnames(resume$which)[resume$which[which.min(resume$bic),]][-1]
formule <- formula(paste("O3~",paste(nomselec,collapse="+")))
modeleslectionne <- lm(formule, data = ozone)
modeleslectionne

Call:
lm(formula = formule, data = ozone)

Coefficients:
(Intercept)          T15         Ne12           Vx          O3v  
    61.8252       1.0577      -3.9935       0.3146       0.2629