rm(list=ls())
require(MASS)
library(leaps)
ozone <- read.table("ozone.txt", header=T, row.names=1, sep=";");
attach(ozone) #names(ozone)

modtot <- lm(maxO3~., data=ozone).html
summary(modtot)

mod2 <- update(modtot, ~.-VENT12); summary(mod2)
mod3 <- update(mod2, ~.-T12); summary(mod3)
mod4 <- update(mod3, ~.-E12); summary(mod4)
mod5 <- update(mod4, ~.-N12); summary(mod5)
mod6 <- update(mod5, ~.-W12); summary(mod6)
mod7 <- update(mod6, ~.-S12); summary(mod7)

exhaustive <- regsubsets(maxO3~., int=T, nbest=1, nvmax=10, method="exhaustive", data=ozone).html
plot(exhaustive, scale="r2") #scale="BIC" scale="adjr2" scale="Cp"

mod0 <- lm(maxO3~1, data=ozone)%3b.html
summary(mod0);
modF <- step(mod0, list(upper=modtot), direction = "forward");
summary(modF)
