bs1<-lm(Fertility~Education + Catholic, swiss)
step(bs1, direction = "forward")
## Start: AIC=202.18
## Fertility ~ Education + Catholic
##
## Call:
## lm(formula = Fertility ~ Education + Catholic, data = swiss)
##
## Coefficients:
## (Intercept) Education Catholic
## 74.2337 -0.7883 0.1109
step(bs1, direction = "both")
## Start: AIC=202.18
## Fertility ~ Education + Catholic
##
## Df Sum of Sq RSS AIC
## <none> 3054.2 202.18
## - Catholic 1 961.07 4015.2 213.04
## - Education 1 2580.50 5634.7 228.97
##
## Call:
## lm(formula = Fertility ~ Education + Catholic, data = swiss)
##
## Coefficients:
## (Intercept) Education Catholic
## 74.2337 -0.7883 0.1109
step(bs1, direction = "backward")
## Start: AIC=202.18
## Fertility ~ Education + Catholic
##
## Df Sum of Sq RSS AIC
## <none> 3054.2 202.18
## - Catholic 1 961.07 4015.2 213.04
## - Education 1 2580.50 5634.7 228.97
##
## Call:
## lm(formula = Fertility ~ Education + Catholic, data = swiss)
##
## Coefficients:
## (Intercept) Education Catholic
## 74.2337 -0.7883 0.1109
bs2<-lm(Fertility ~ Education + Catholic + Infant.Mortality, swiss)
step(bs2, direction = "forward")
## Start: AIC=193.29
## Fertility ~ Education + Catholic + Infant.Mortality
##
## Call:
## lm(formula = Fertility ~ Education + Catholic + Infant.Mortality,
## data = swiss)
##
## Coefficients:
## (Intercept) Education Catholic Infant.Mortality
## 48.67707 -0.75925 0.09607 1.29615
step(bs2, direction = "both")
## Start: AIC=193.29
## Fertility ~ Education + Catholic + Infant.Mortality
##
## Df Sum of Sq RSS AIC
## <none> 2422.2 193.29
## - Infant.Mortality 1 631.92 3054.2 202.18
## - Catholic 1 701.74 3124.0 203.25
## - Education 1 2380.38 4802.6 223.46
##
## Call:
## lm(formula = Fertility ~ Education + Catholic + Infant.Mortality,
## data = swiss)
##
## Coefficients:
## (Intercept) Education Catholic Infant.Mortality
## 48.67707 -0.75925 0.09607 1.29615
step(bs2, direction = "backward")
## Start: AIC=193.29
## Fertility ~ Education + Catholic + Infant.Mortality
##
## Df Sum of Sq RSS AIC
## <none> 2422.2 193.29
## - Infant.Mortality 1 631.92 3054.2 202.18
## - Catholic 1 701.74 3124.0 203.25
## - Education 1 2380.38 4802.6 223.46
##
## Call:
## lm(formula = Fertility ~ Education + Catholic + Infant.Mortality,
## data = swiss)
##
## Coefficients:
## (Intercept) Education Catholic Infant.Mortality
## 48.67707 -0.75925 0.09607 1.29615
bs3<-lm(Fertility ~ Education + Catholic + Infant.Mortality + Agriculture, swiss)
step(bs3, direction = "forward")
## Start: AIC=189.86
## Fertility ~ Education + Catholic + Infant.Mortality + Agriculture
##
## Call:
## lm(formula = Fertility ~ Education + Catholic + Infant.Mortality +
## Agriculture, data = swiss)
##
## Coefficients:
## (Intercept) Education Catholic Infant.Mortality
## 62.1013 -0.9803 0.1247 1.0784
## Agriculture
## -0.1546
step(bs3, direction = "both")
## Start: AIC=189.86
## Fertility ~ Education + Catholic + Infant.Mortality + Agriculture
##
## Df Sum of Sq RSS AIC
## <none> 2158.1 189.86
## - Agriculture 1 264.18 2422.2 193.29
## - Infant.Mortality 1 409.81 2567.9 196.03
## - Catholic 1 956.57 3114.6 205.10
## - Education 1 2249.97 4408.0 221.43
##
## Call:
## lm(formula = Fertility ~ Education + Catholic + Infant.Mortality +
## Agriculture, data = swiss)
##
## Coefficients:
## (Intercept) Education Catholic Infant.Mortality
## 62.1013 -0.9803 0.1247 1.0784
## Agriculture
## -0.1546
step(bs3, direction = "backward")
## Start: AIC=189.86
## Fertility ~ Education + Catholic + Infant.Mortality + Agriculture
##
## Df Sum of Sq RSS AIC
## <none> 2158.1 189.86
## - Agriculture 1 264.18 2422.2 193.29
## - Infant.Mortality 1 409.81 2567.9 196.03
## - Catholic 1 956.57 3114.6 205.10
## - Education 1 2249.97 4408.0 221.43
##
## Call:
## lm(formula = Fertility ~ Education + Catholic + Infant.Mortality +
## Agriculture, data = swiss)
##
## Coefficients:
## (Intercept) Education Catholic Infant.Mortality
## 62.1013 -0.9803 0.1247 1.0784
## Agriculture
## -0.1546