attach(swiss)
bs.out2<-lm(Fertility ~., swiss)
step(bs.out2,direction = "forward")
## Start: AIC=190.69
## Fertility ~ Agriculture + Examination + Education + Catholic +
## Infant.Mortality
##
## Call:
## lm(formula = Fertility ~ Agriculture + Examination + Education +
## Catholic + Infant.Mortality, data = swiss)
##
## Coefficients:
## (Intercept) Agriculture Examination Education
## 66.9152 -0.1721 -0.2580 -0.8709
## Catholic Infant.Mortality
## 0.1041 1.0770
step(bs.out2,direction = "both")
## Start: AIC=190.69
## Fertility ~ Agriculture + Examination + Education + Catholic +
## Infant.Mortality
##
## Df Sum of Sq RSS AIC
## - Examination 1 53.03 2158.1 189.86
## <none> 2105.0 190.69
## - Agriculture 1 307.72 2412.8 195.10
## - Infant.Mortality 1 408.75 2513.8 197.03
## - Catholic 1 447.71 2552.8 197.75
## - Education 1 1162.56 3267.6 209.36
##
## Step: AIC=189.86
## Fertility ~ Agriculture + Education + Catholic + Infant.Mortality
##
## Df Sum of Sq RSS AIC
## <none> 2158.1 189.86
## + Examination 1 53.03 2105.0 190.69
## - 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 ~ Agriculture + Education + Catholic +
## Infant.Mortality, data = swiss)
##
## Coefficients:
## (Intercept) Agriculture Education Catholic
## 62.1013 -0.1546 -0.9803 0.1247
## Infant.Mortality
## 1.0784
step(bs.out2,direction = "backward")
## Start: AIC=190.69
## Fertility ~ Agriculture + Examination + Education + Catholic +
## Infant.Mortality
##
## Df Sum of Sq RSS AIC
## - Examination 1 53.03 2158.1 189.86
## <none> 2105.0 190.69
## - Agriculture 1 307.72 2412.8 195.10
## - Infant.Mortality 1 408.75 2513.8 197.03
## - Catholic 1 447.71 2552.8 197.75
## - Education 1 1162.56 3267.6 209.36
##
## Step: AIC=189.86
## Fertility ~ Agriculture + Education + Catholic + Infant.Mortality
##
## 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 ~ Agriculture + Education + Catholic +
## Infant.Mortality, data = swiss)
##
## Coefficients:
## (Intercept) Agriculture Education Catholic
## 62.1013 -0.1546 -0.9803 0.1247
## Infant.Mortality
## 1.0784
bs.out3<-lm(Fertility ~Education+Catholic, swiss)
step(bs.out3,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(bs.out3,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(bs.out3,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
bs.out4<-lm(Fertility ~Education+Catholic+Infant.Mortality, swiss)
step(bs.out4,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(bs.out4,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(bs.out4,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
bs.out5<-lm(Fertility ~Education+Catholic+Infant.Mortality+Agriculture, swiss)
step(bs.out5,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(bs.out5,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(bs.out5,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
bs.out6<-lm(Fertility ~Education+Catholic+Infant.Mortality+Agriculture+Examination, swiss)
step(bs.out6,direction = "forward")
## Start: AIC=190.69
## Fertility ~ Education + Catholic + Infant.Mortality + Agriculture +
## Examination
##
## Call:
## lm(formula = Fertility ~ Education + Catholic + Infant.Mortality +
## Agriculture + Examination, data = swiss)
##
## Coefficients:
## (Intercept) Education Catholic Infant.Mortality
## 66.9152 -0.8709 0.1041 1.0770
## Agriculture Examination
## -0.1721 -0.2580
step(bs.out6,direction = "both")
## Start: AIC=190.69
## Fertility ~ Education + Catholic + Infant.Mortality + Agriculture +
## Examination
##
## Df Sum of Sq RSS AIC
## - Examination 1 53.03 2158.1 189.86
## <none> 2105.0 190.69
## - Agriculture 1 307.72 2412.8 195.10
## - Infant.Mortality 1 408.75 2513.8 197.03
## - Catholic 1 447.71 2552.8 197.75
## - Education 1 1162.56 3267.6 209.36
##
## Step: AIC=189.86
## Fertility ~ Education + Catholic + Infant.Mortality + Agriculture
##
## Df Sum of Sq RSS AIC
## <none> 2158.1 189.86
## + Examination 1 53.03 2105.0 190.69
## - 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(bs.out6,direction = "backward")
## Start: AIC=190.69
## Fertility ~ Education + Catholic + Infant.Mortality + Agriculture +
## Examination
##
## Df Sum of Sq RSS AIC
## - Examination 1 53.03 2158.1 189.86
## <none> 2105.0 190.69
## - Agriculture 1 307.72 2412.8 195.10
## - Infant.Mortality 1 408.75 2513.8 197.03
## - Catholic 1 447.71 2552.8 197.75
## - Education 1 1162.56 3267.6 209.36
##
## Step: 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