You are on page 1of 42

solution to quiz 4

Jiecheng Song

3/30/2020

read data
data <- read.csv('~/Desktop/math.csv',header = T,sep = ';')

question 1
There are too many variables in the model if we directly include all the interaction variables, so first we have
a look at the model without interactions.
fit1 <- glm((G1+G2+G3)/3 ~ . ,data= data)
#AIC
fit1_step <- step(fit1, k = 2)

## Start: AIC=2087.56
## (G1 + G2 + G3)/3 ~ school + sex + age + address + famsize + Pstatus +
## Medu + Fedu + Mjob + Fjob + reason + guardian + traveltime +
## studytime + failures + schoolsup + famsup + paid + activities +
## nursery + higher + internet + romantic + famrel + freetime +
## goout + Dalc + Walc + health + absences
##
## Df Deviance AIC
## - reason 3 3721.9 2083.0
## - guardian 2 3719.8 2084.8
## - Fedu 1 3708.5 2085.6
## - nursery 1 3708.6 2085.6
## - famrel 1 3709.0 2085.6
## - Pstatus 1 3709.1 2085.6
## - activities 1 3709.7 2085.7
## - paid 1 3710.8 2085.8
## - school 1 3711.4 2085.9
## - Dalc 1 3711.4 2085.9
## - Walc 1 3711.9 2085.9
## - traveltime 1 3714.6 2086.2
## - address 1 3715.6 2086.3
## - internet 1 3717.7 2086.5
## - absences 1 3721.8 2087.0
## - Medu 1 3722.8 2087.1
## - age 1 3724.9 2087.3
## <none> 3708.5 2087.6
## - higher 1 3728.1 2087.6
## - freetime 1 3728.4 2087.7
## - Fjob 4 3786.5 2087.8
## - health 1 3731.3 2088.0
## - famsize 1 3732.4 2088.1

1
## - romantic 1 3746.9 2089.6
## - famsup 1 3769.6 2092.0
## - studytime 1 3775.4 2092.6
## - sex 1 3781.4 2093.2
## - Mjob 4 3851.9 2094.6
## - goout 1 3798.8 2095.1
## - schoolsup 1 3812.6 2096.5
## - failures 1 4037.9 2119.2
##
## Step: AIC=2082.99
## (G1 + G2 + G3)/3 ~ school + sex + age + address + famsize + Pstatus +
## Medu + Fedu + Mjob + Fjob + guardian + traveltime + studytime +
## failures + schoolsup + famsup + paid + activities + nursery +
## higher + internet + romantic + famrel + freetime + goout +
## Dalc + Walc + health + absences
##
## Df Deviance AIC
## - guardian 2 3734.3 2080.3
## - Fedu 1 3721.9 2081.0
## - nursery 1 3722.0 2081.0
## - activities 1 3722.4 2081.0
## - Pstatus 1 3722.4 2081.0
## - famrel 1 3722.4 2081.0
## - school 1 3724.3 2081.2
## - Dalc 1 3725.0 2081.3
## - paid 1 3725.4 2081.4
## - Walc 1 3725.8 2081.4
## - address 1 3727.3 2081.6
## - traveltime 1 3728.9 2081.7
## - internet 1 3731.1 2082.0
## - Medu 1 3737.9 2082.7
## - absences 1 3738.1 2082.7
## - age 1 3738.3 2082.7
## <none> 3721.9 2083.0
## - higher 1 3741.0 2083.0
## - freetime 1 3741.8 2083.1
## - famsize 1 3746.0 2083.5
## - Fjob 4 3804.8 2083.7
## - health 1 3751.9 2084.2
## - romantic 1 3760.9 2085.1
## - famsup 1 3782.3 2087.3
## - sex 1 3792.9 2088.4
## - studytime 1 3793.3 2088.5
## - goout 1 3817.2 2091.0
## - Mjob 4 3879.6 2091.4
## - schoolsup 1 3827.6 2092.1
## - failures 1 4059.2 2115.3
##
## Step: AIC=2080.3
## (G1 + G2 + G3)/3 ~ school + sex + age + address + famsize + Pstatus +
## Medu + Fedu + Mjob + Fjob + traveltime + studytime + failures +
## schoolsup + famsup + paid + activities + nursery + higher +
## internet + romantic + famrel + freetime + goout + Dalc +
## Walc + health + absences

2
##
## Df Deviance AIC
## - Fedu 1 3734.5 2078.3
## - activities 1 3734.8 2078.4
## - nursery 1 3734.9 2078.4
## - famrel 1 3734.9 2078.4
## - Pstatus 1 3735.2 2078.4
## - school 1 3735.9 2078.5
## - Dalc 1 3736.8 2078.6
## - Walc 1 3736.8 2078.6
## - paid 1 3738.3 2078.7
## - traveltime 1 3739.7 2078.9
## - address 1 3742.1 2079.1
## - internet 1 3742.8 2079.2
## - age 1 3743.2 2079.2
## - Medu 1 3748.2 2079.8
## - absences 1 3753.2 2080.3
## <none> 3734.3 2080.3
## - Fjob 4 3813.5 2080.6
## - famsize 1 3757.2 2080.7
## - freetime 1 3758.0 2080.8
## - higher 1 3758.2 2080.8
## - health 1 3766.2 2081.7
## - romantic 1 3770.9 2082.2
## - famsup 1 3793.3 2084.5
## - sex 1 3806.4 2085.9
## - studytime 1 3809.9 2086.2
## - Mjob 4 3894.2 2088.9
## - goout 1 3837.9 2089.1
## - schoolsup 1 3838.7 2089.2
## - failures 1 4060.4 2111.4
##
## Step: AIC=2078.32
## (G1 + G2 + G3)/3 ~ school + sex + age + address + famsize + Pstatus +
## Medu + Mjob + Fjob + traveltime + studytime + failures +
## schoolsup + famsup + paid + activities + nursery + higher +
## internet + romantic + famrel + freetime + goout + Dalc +
## Walc + health + absences
##
## Df Deviance AIC
## - activities 1 3734.9 2076.4
## - nursery 1 3735.0 2076.4
## - famrel 1 3735.1 2076.4
## - Pstatus 1 3735.3 2076.4
## - school 1 3736.1 2076.5
## - Dalc 1 3737.0 2076.6
## - Walc 1 3737.1 2076.6
## - paid 1 3738.4 2076.7
## - traveltime 1 3740.1 2076.9
## - address 1 3742.1 2077.1
## - internet 1 3743.1 2077.2
## - age 1 3743.4 2077.3
## - absences 1 3753.3 2078.3
## <none> 3734.5 2078.3

3
## - Medu 1 3754.9 2078.5
## - famsize 1 3757.2 2078.7
## - freetime 1 3758.0 2078.8
## - higher 1 3758.9 2078.9
## - Fjob 4 3823.6 2079.6
## - health 1 3766.2 2079.7
## - romantic 1 3771.0 2080.2
## - famsup 1 3793.6 2082.5
## - sex 1 3806.5 2083.9
## - studytime 1 3810.5 2084.3
## - Mjob 4 3894.2 2086.9
## - goout 1 3837.9 2087.1
## - schoolsup 1 3838.7 2087.2
## - failures 1 4068.5 2110.2
##
## Step: AIC=2076.37
## (G1 + G2 + G3)/3 ~ school + sex + age + address + famsize + Pstatus +
## Medu + Mjob + Fjob + traveltime + studytime + failures +
## schoolsup + famsup + paid + nursery + higher + internet +
## romantic + famrel + freetime + goout + Dalc + Walc + health +
## absences
##
## Df Deviance AIC
## - nursery 1 3735.4 2074.4
## - famrel 1 3735.5 2074.4
## - Pstatus 1 3735.9 2074.5
## - school 1 3736.7 2074.6
## - Dalc 1 3737.3 2074.6
## - Walc 1 3737.6 2074.7
## - paid 1 3738.9 2074.8
## - traveltime 1 3740.7 2075.0
## - address 1 3743.0 2075.2
## - internet 1 3743.6 2075.3
## - age 1 3743.7 2075.3
## - absences 1 3753.6 2076.3
## <none> 3734.9 2076.4
## - Medu 1 3755.1 2076.5
## - famsize 1 3757.5 2076.8
## - freetime 1 3758.1 2076.8
## - higher 1 3758.9 2076.9
## - health 1 3766.7 2077.7
## - Fjob 4 3824.7 2077.8
## - romantic 1 3772.2 2078.3
## - famsup 1 3793.7 2080.5
## - sex 1 3806.6 2081.9
## - studytime 1 3810.5 2082.3
## - Mjob 4 3894.7 2084.9
## - goout 1 3839.8 2085.3
## - schoolsup 1 3840.5 2085.4
## - failures 1 4068.5 2108.2
##
## Step: AIC=2074.42
## (G1 + G2 + G3)/3 ~ school + sex + age + address + famsize + Pstatus +
## Medu + Mjob + Fjob + traveltime + studytime + failures +

4
## schoolsup + famsup + paid + higher + internet + romantic +
## famrel + freetime + goout + Dalc + Walc + health + absences
##
## Df Deviance AIC
## - famrel 1 3736.0 2072.5
## - Pstatus 1 3736.3 2072.5
## - school 1 3737.3 2072.6
## - Dalc 1 3737.6 2072.7
## - Walc 1 3738.2 2072.7
## - paid 1 3739.2 2072.8
## - traveltime 1 3741.3 2073.0
## - address 1 3743.5 2073.3
## - age 1 3744.1 2073.3
## - internet 1 3744.3 2073.4
## - absences 1 3754.0 2074.4
## <none> 3735.4 2074.4
## - Medu 1 3755.1 2074.5
## - famsize 1 3757.6 2074.8
## - freetime 1 3758.7 2074.9
## - higher 1 3759.5 2074.9
## - health 1 3767.2 2075.8
## - Fjob 4 3824.9 2075.8
## - romantic 1 3772.9 2076.4
## - famsup 1 3794.1 2078.6
## - sex 1 3806.7 2079.9
## - studytime 1 3810.6 2080.3
## - Mjob 4 3895.0 2082.9
## - goout 1 3841.3 2083.5
## - schoolsup 1 3841.7 2083.5
## - failures 1 4068.5 2106.2
##
## Step: AIC=2072.48
## (G1 + G2 + G3)/3 ~ school + sex + age + address + famsize + Pstatus +
## Medu + Mjob + Fjob + traveltime + studytime + failures +
## schoolsup + famsup + paid + higher + internet + romantic +
## freetime + goout + Dalc + Walc + health + absences
##
## Df Deviance AIC
## - Pstatus 1 3737.0 2070.6
## - school 1 3737.8 2070.7
## - Dalc 1 3738.4 2070.7
## - Walc 1 3738.5 2070.7
## - paid 1 3739.9 2070.9
## - traveltime 1 3741.8 2071.1
## - address 1 3744.0 2071.3
## - age 1 3744.2 2071.3
## - internet 1 3745.2 2071.4
## - absences 1 3754.4 2072.4
## <none> 3736.0 2072.5
## - Medu 1 3756.1 2072.6
## - famsize 1 3758.2 2072.8
## - higher 1 3760.4 2073.1
## - freetime 1 3761.1 2073.1
## - health 1 3767.2 2073.8

5
## - Fjob 4 3824.9 2073.8
## - romantic 1 3774.3 2074.5
## - famsup 1 3795.1 2076.7
## - sex 1 3808.5 2078.1
## - studytime 1 3811.3 2078.4
## - Mjob 4 3895.5 2081.0
## - goout 1 3841.3 2081.5
## - schoolsup 1 3842.0 2081.5
## - failures 1 4072.4 2104.5
##
## Step: AIC=2070.58
## (G1 + G2 + G3)/3 ~ school + sex + age + address + famsize + Medu +
## Mjob + Fjob + traveltime + studytime + failures + schoolsup +
## famsup + paid + higher + internet + romantic + freetime +
## goout + Dalc + Walc + health + absences
##
## Df Deviance AIC
## - school 1 3738.7 2068.8
## - Dalc 1 3739.2 2068.8
## - Walc 1 3739.4 2068.8
## - paid 1 3740.7 2069.0
## - traveltime 1 3742.8 2069.2
## - address 1 3745.1 2069.4
## - age 1 3745.4 2069.5
## - internet 1 3745.6 2069.5
## <none> 3737.0 2070.6
## - absences 1 3756.5 2070.6
## - Medu 1 3758.6 2070.9
## - famsize 1 3761.2 2071.1
## - higher 1 3761.6 2071.2
## - freetime 1 3761.7 2071.2
## - health 1 3768.5 2071.9
## - Fjob 4 3826.9 2072.0
## - romantic 1 3775.0 2072.6
## - famsup 1 3796.5 2074.8
## - sex 1 3809.1 2076.1
## - studytime 1 3812.0 2076.4
## - Mjob 4 3897.8 2079.2
## - goout 1 3842.4 2079.6
## - schoolsup 1 3842.7 2079.6
## - failures 1 4072.6 2102.6
##
## Step: AIC=2068.77
## (G1 + G2 + G3)/3 ~ sex + age + address + famsize + Medu + Mjob +
## Fjob + traveltime + studytime + failures + schoolsup + famsup +
## paid + higher + internet + romantic + freetime + goout +
## Dalc + Walc + health + absences
##
## Df Deviance AIC
## - Dalc 1 3740.8 2067.0
## - Walc 1 3741.0 2067.0
## - paid 1 3742.7 2067.2
## - traveltime 1 3743.7 2067.3
## - age 1 3745.5 2067.5

6
## - address 1 3745.7 2067.5
## - internet 1 3747.1 2067.7
## - absences 1 3756.8 2068.7
## <none> 3738.7 2068.8
## - Medu 1 3760.3 2069.1
## - famsize 1 3763.6 2069.4
## - freetime 1 3764.3 2069.5
## - higher 1 3764.6 2069.5
## - health 1 3770.6 2070.1
## - Fjob 4 3829.1 2070.2
## - romantic 1 3776.3 2070.7
## - famsup 1 3801.3 2073.3
## - sex 1 3809.6 2074.2
## - studytime 1 3812.0 2074.4
## - Mjob 4 3898.6 2077.3
## - goout 1 3845.6 2077.9
## - schoolsup 1 3845.7 2077.9
## - failures 1 4077.7 2101.1
##
## Step: AIC=2066.99
## (G1 + G2 + G3)/3 ~ sex + age + address + famsize + Medu + Mjob +
## Fjob + traveltime + studytime + failures + schoolsup + famsup +
## paid + higher + internet + romantic + freetime + goout +
## Walc + health + absences
##
## Df Deviance AIC
## - Walc 1 3741.5 2065.1
## - paid 1 3744.4 2065.4
## - traveltime 1 3746.3 2065.6
## - address 1 3748.0 2065.7
## - age 1 3748.4 2065.8
## - internet 1 3749.0 2065.8
## - absences 1 3758.8 2066.9
## <none> 3740.8 2067.0
## - Medu 1 3761.3 2067.1
## - freetime 1 3764.8 2067.5
## - famsize 1 3765.0 2067.5
## - higher 1 3766.1 2067.7
## - Fjob 4 3829.2 2068.2
## - health 1 3773.2 2068.4
## - romantic 1 3778.4 2068.9
## - famsup 1 3804.1 2071.6
## - sex 1 3809.9 2072.2
## - studytime 1 3814.8 2072.7
## - Mjob 4 3904.0 2075.8
## - goout 1 3846.5 2076.0
## - schoolsup 1 3850.2 2076.4
## - failures 1 4083.4 2099.6
##
## Step: AIC=2065.07
## (G1 + G2 + G3)/3 ~ sex + age + address + famsize + Medu + Mjob +
## Fjob + traveltime + studytime + failures + schoolsup + famsup +
## paid + higher + internet + romantic + freetime + goout +
## health + absences

7
##
## Df Deviance AIC
## - paid 1 3745.8 2063.5
## - traveltime 1 3746.8 2063.6
## - address 1 3748.3 2063.8
## - age 1 3749.1 2063.9
## - internet 1 3749.7 2063.9
## <none> 3741.5 2065.1
## - absences 1 3761.0 2065.1
## - Medu 1 3761.8 2065.2
## - freetime 1 3765.5 2065.6
## - famsize 1 3766.6 2065.7
## - higher 1 3766.9 2065.7
## - Fjob 4 3829.2 2066.2
## - health 1 3773.3 2066.4
## - romantic 1 3779.3 2067.0
## - famsup 1 3805.6 2069.8
## - studytime 1 3815.1 2070.8
## - sex 1 3817.0 2070.9
## - Mjob 4 3904.9 2073.9
## - schoolsup 1 3851.3 2074.5
## - goout 1 3859.7 2075.3
## - failures 1 4083.4 2097.6
##
## Step: AIC=2063.51
## (G1 + G2 + G3)/3 ~ sex + age + address + famsize + Medu + Mjob +
## Fjob + traveltime + studytime + failures + schoolsup + famsup +
## higher + internet + romantic + freetime + goout + health +
## absences
##
## Df Deviance AIC
## - traveltime 1 3751.3 2062.1
## - address 1 3752.6 2062.2
## - age 1 3752.8 2062.2
## - internet 1 3755.2 2062.5
## <none> 3745.8 2063.5
## - absences 1 3765.0 2063.5
## - Medu 1 3766.0 2063.6
## - freetime 1 3768.8 2063.9
## - famsize 1 3770.8 2064.2
## - Fjob 4 3830.4 2064.3
## - higher 1 3773.7 2064.4
## - health 1 3779.1 2065.0
## - romantic 1 3783.2 2065.4
## - famsup 1 3805.6 2067.8
## - sex 1 3819.5 2069.2
## - studytime 1 3821.5 2069.4
## - Mjob 4 3908.0 2072.3
## - schoolsup 1 3857.0 2073.1
## - goout 1 3862.4 2073.6
## - failures 1 4101.8 2097.4
##
## Step: AIC=2062.1
## (G1 + G2 + G3)/3 ~ sex + age + address + famsize + Medu + Mjob +

8
## Fjob + studytime + failures + schoolsup + famsup + higher +
## internet + romantic + freetime + goout + health + absences
##
## Df Deviance AIC
## - age 1 3758.2 2060.8
## - internet 1 3760.7 2061.1
## - address 1 3763.3 2061.4
## <none> 3751.3 2062.1
## - absences 1 3771.2 2062.2
## - Medu 1 3773.1 2062.4
## - famsize 1 3774.4 2062.5
## - freetime 1 3775.2 2062.6
## - Fjob 4 3836.2 2062.9
## - higher 1 3779.7 2063.1
## - health 1 3784.3 2063.6
## - romantic 1 3789.9 2064.1
## - famsup 1 3813.9 2066.6
## - sex 1 3823.6 2067.6
## - studytime 1 3830.9 2068.4
## - Mjob 4 3916.0 2071.1
## - schoolsup 1 3862.6 2071.6
## - goout 1 3871.1 2072.5
## - failures 1 4110.1 2096.2
##
## Step: AIC=2060.82
## (G1 + G2 + G3)/3 ~ sex + address + famsize + Medu + Mjob + Fjob +
## studytime + failures + schoolsup + famsup + higher + internet +
## romantic + freetime + goout + health + absences
##
## Df Deviance AIC
## - internet 1 3769.7 2060.0
## - address 1 3772.3 2060.3
## - absences 1 3774.7 2060.6
## <none> 3758.2 2060.8
## - famsize 1 3780.9 2061.2
## - freetime 1 3782.5 2061.4
## - Medu 1 3782.7 2061.4
## - Fjob 4 3843.4 2061.7
## - health 1 3788.9 2062.0
## - higher 1 3790.6 2062.2
## - romantic 1 3801.0 2063.3
## - famsup 1 3817.8 2065.0
## - sex 1 3832.8 2066.6
## - studytime 1 3834.7 2066.8
## - schoolsup 1 3862.6 2069.6
## - Mjob 4 3924.5 2069.9
## - goout 1 3887.8 2072.2
## - failures 1 4142.0 2097.2
##
## Step: AIC=2060.03
## (G1 + G2 + G3)/3 ~ sex + address + famsize + Medu + Mjob + Fjob +
## studytime + failures + schoolsup + famsup + higher + romantic +
## freetime + goout + health + absences
##

9
## Df Deviance AIC
## <none> 3769.7 2060.0
## - absences 1 3789.0 2060.1
## - address 1 3789.4 2060.1
## - famsize 1 3791.3 2060.3
## - Fjob 4 3850.8 2060.4
## - freetime 1 3794.4 2060.6
## - Medu 1 3794.4 2060.6
## - higher 1 3801.3 2061.3
## - health 1 3804.4 2061.7
## - romantic 1 3808.9 2062.1
## - famsup 1 3825.4 2063.8
## - sex 1 3848.5 2066.2
## - studytime 1 3851.1 2066.5
## - schoolsup 1 3872.6 2068.7
## - Mjob 4 3937.7 2069.2
## - goout 1 3895.7 2071.0
## - failures 1 4160.2 2097.0
#BIC
#fit1_step <- step(fit1, k = log(395))
summary(fit1_step)

##
## Call:
## glm(formula = (G1 + G2 + G3)/3 ~ sex + address + famsize + Medu +
## Mjob + Fjob + studytime + failures + schoolsup + famsup +
## higher + romantic + freetime + goout + health + absences,
## data = data)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -9.2633 -2.0458 0.2152 2.1836 6.9220
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.30242 1.46265 6.360 5.92e-10 ***
## sexM 1.02443 0.36738 2.788 0.005568 **
## addressU 0.55442 0.39765 1.394 0.164078
## famsizeLE3 0.53431 0.36637 1.458 0.145572
## Medu 0.32484 0.20819 1.560 0.119541
## Mjobhealth 1.33864 0.82294 1.627 0.104657
## Mjobother -0.32444 0.52826 -0.614 0.539486
## Mjobservices 0.75640 0.59526 1.271 0.204633
## Mjobteacher -0.91135 0.77182 -1.181 0.238446
## Fjobhealth 0.18474 1.07558 0.172 0.863719
## Fjobother -0.61877 0.76338 -0.811 0.418138
## Fjobservices -0.36342 0.79415 -0.458 0.647491
## Fjobteacher 1.19467 0.96690 1.236 0.217400
## studytime 0.59567 0.21026 2.833 0.004862 **
## failures -1.48765 0.23966 -6.207 1.44e-09 ***
## schoolsupyes -1.58160 0.49631 -3.187 0.001561 **
## famsupyes -0.81631 0.34824 -2.344 0.019598 *
## higheryes 1.40608 0.79708 1.764 0.078545 .
## romanticyes -0.69924 0.35568 -1.966 0.050049 .

10
## freetime 0.27448 0.17599 1.560 0.119711
## goout -0.54067 0.15332 -3.526 0.000474 ***
## health -0.22147 0.11974 -1.850 0.065174 .
## absences 0.02883 0.02089 1.380 0.168311
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 10.13366)
##
## Null deviance: 5384.5 on 394 degrees of freedom
## Residual deviance: 3769.7 on 372 degrees of freedom
## AIC: 2060
##
## Number of Fisher Scoring iterations: 2
The goodness-of-fit index is AIC: 2060.
Then we can choose some significant variables and consider interaction variables.
fit2 <- glm((G1+G2+G3)/3 ~(sex + studytime + failures + schoolsup + famsup + higher + romantic + goout +
#AIC
fit2_step <- step(fit2, k = 2)

## Start: AIC=2105.32
## (G1 + G2 + G3)/3 ~ (sex + studytime + failures + schoolsup +
## famsup + higher + romantic + goout + health)^2
##
## Df Deviance AIC
## - romantic:health 1 3762.9 2103.3
## - romantic:goout 1 3762.9 2103.3
## - sex:health 1 3763.0 2103.3
## - failures:famsup 1 3763.1 2103.3
## - famsup:goout 1 3763.2 2103.3
## - higher:health 1 3763.5 2103.4
## - schoolsup:higher 1 3763.5 2103.4
## - famsup:higher 1 3763.8 2103.4
## - studytime:romantic 1 3763.8 2103.4
## - failures:romantic 1 3764.2 2103.4
## - sex:goout 1 3764.3 2103.5
## - goout:health 1 3764.3 2103.5
## - famsup:health 1 3764.8 2103.5
## - famsup:romantic 1 3764.9 2103.5
## - sex:higher 1 3765.0 2103.5
## - sex:studytime 1 3765.3 2103.6
## - studytime:health 1 3766.1 2103.7
## - schoolsup:romantic 1 3766.1 2103.7
## - studytime:higher 1 3766.8 2103.7
## - failures:schoolsup 1 3768.8 2103.9
## - failures:health 1 3770.9 2104.2
## - higher:romantic 1 3771.9 2104.3
## - schoolsup:goout 1 3772.0 2104.3
## - schoolsup:famsup 1 3773.4 2104.4
## - studytime:failures 1 3773.5 2104.4
## - sex:romantic 1 3776.8 2104.8
## - sex:famsup 1 3778.7 2105.0
## <none> 3762.9 2105.3

11
## - sex:failures 1 3785.7 2105.7
## - sex:schoolsup 1 3785.9 2105.7
## - studytime:goout 1 3789.7 2106.1
## - failures:higher 1 3790.9 2106.2
## - higher:goout 1 3791.1 2106.3
## - schoolsup:health 1 3809.3 2108.2
## - failures:goout 1 3811.6 2108.4
## - studytime:famsup 1 3819.3 2109.2
## - studytime:schoolsup 1 3856.2 2113.0
##
## Step: AIC=2103.32
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + sex:health + studytime:failures + studytime:schoolsup +
## studytime:famsup + studytime:higher + studytime:romantic +
## studytime:goout + studytime:health + failures:schoolsup +
## failures:famsup + failures:higher + failures:romantic + failures:goout +
## failures:health + schoolsup:famsup + schoolsup:higher + schoolsup:romantic +
## schoolsup:goout + schoolsup:health + famsup:higher + famsup:romantic +
## famsup:goout + famsup:health + higher:romantic + higher:goout +
## higher:health + romantic:goout + goout:health
##
## Df Deviance AIC
## - romantic:goout 1 3762.9 2101.3
## - sex:health 1 3763.0 2101.3
## - failures:famsup 1 3763.1 2101.3
## - famsup:goout 1 3763.2 2101.3
## - higher:health 1 3763.5 2101.4
## - schoolsup:higher 1 3763.5 2101.4
## - studytime:romantic 1 3763.8 2101.4
## - famsup:higher 1 3763.8 2101.4
## - failures:romantic 1 3764.2 2101.4
## - goout:health 1 3764.3 2101.5
## - sex:goout 1 3764.3 2101.5
## - famsup:health 1 3764.8 2101.5
## - famsup:romantic 1 3765.0 2101.5
## - sex:higher 1 3765.1 2101.5
## - sex:studytime 1 3765.3 2101.6
## - studytime:health 1 3766.1 2101.7
## - schoolsup:romantic 1 3766.1 2101.7
## - studytime:higher 1 3766.8 2101.7
## - failures:schoolsup 1 3768.9 2101.9
## - failures:health 1 3771.0 2102.2
## - higher:romantic 1 3771.9 2102.3
## - schoolsup:goout 1 3772.1 2102.3
## - schoolsup:famsup 1 3773.4 2102.4
## - studytime:failures 1 3773.6 2102.4
## - sex:romantic 1 3777.0 2102.8
## - sex:famsup 1 3778.9 2103.0
## <none> 3762.9 2103.3
## - sex:failures 1 3786.1 2103.7
## - sex:schoolsup 1 3786.1 2103.7
## - studytime:goout 1 3790.7 2104.2

12
## - failures:higher 1 3791.1 2104.3
## - higher:goout 1 3791.6 2104.3
## - schoolsup:health 1 3809.9 2106.2
## - failures:goout 1 3811.9 2106.4
## - studytime:famsup 1 3819.3 2107.2
## - studytime:schoolsup 1 3856.8 2111.1
##
## Step: AIC=2101.32
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + sex:health + studytime:failures + studytime:schoolsup +
## studytime:famsup + studytime:higher + studytime:romantic +
## studytime:goout + studytime:health + failures:schoolsup +
## failures:famsup + failures:higher + failures:romantic + failures:goout +
## failures:health + schoolsup:famsup + schoolsup:higher + schoolsup:romantic +
## schoolsup:goout + schoolsup:health + famsup:higher + famsup:romantic +
## famsup:goout + famsup:health + higher:romantic + higher:goout +
## higher:health + goout:health
##
## Df Deviance AIC
## - sex:health 1 3763.0 2099.3
## - failures:famsup 1 3763.1 2099.3
## - famsup:goout 1 3763.2 2099.3
## - higher:health 1 3763.5 2099.4
## - schoolsup:higher 1 3763.6 2099.4
## - studytime:romantic 1 3763.9 2099.4
## - famsup:higher 1 3763.9 2099.4
## - failures:romantic 1 3764.2 2099.5
## - goout:health 1 3764.4 2099.5
## - sex:goout 1 3764.4 2099.5
## - famsup:health 1 3764.8 2099.5
## - famsup:romantic 1 3765.0 2099.5
## - sex:higher 1 3765.1 2099.5
## - sex:studytime 1 3765.3 2099.6
## - schoolsup:romantic 1 3766.2 2099.7
## - studytime:health 1 3766.3 2099.7
## - studytime:higher 1 3766.8 2099.7
## - failures:schoolsup 1 3769.0 2099.9
## - failures:health 1 3771.1 2100.2
## - higher:romantic 1 3772.0 2100.3
## - schoolsup:goout 1 3772.2 2100.3
## - schoolsup:famsup 1 3773.5 2100.4
## - studytime:failures 1 3773.6 2100.4
## - sex:romantic 1 3777.3 2100.8
## - sex:famsup 1 3779.1 2101.0
## <none> 3762.9 2101.3
## - sex:schoolsup 1 3786.1 2101.7
## - sex:failures 1 3786.2 2101.8
## - studytime:goout 1 3791.2 2102.3
## - higher:goout 1 3792.1 2102.4
## - failures:higher 1 3792.2 2102.4
## - schoolsup:health 1 3809.9 2104.2
## - failures:goout 1 3813.2 2104.6

13
## - studytime:famsup 1 3820.0 2105.3
## - studytime:schoolsup 1 3856.9 2109.1
##
## Step: AIC=2099.32
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:higher + studytime:romantic + studytime:goout +
## studytime:health + failures:schoolsup + failures:famsup +
## failures:higher + failures:romantic + failures:goout + failures:health +
## schoolsup:famsup + schoolsup:higher + schoolsup:romantic +
## schoolsup:goout + schoolsup:health + famsup:higher + famsup:romantic +
## famsup:goout + famsup:health + higher:romantic + higher:goout +
## higher:health + goout:health
##
## Df Deviance AIC
## - failures:famsup 1 3763.1 2097.3
## - famsup:goout 1 3763.3 2097.3
## - higher:health 1 3763.6 2097.4
## - schoolsup:higher 1 3763.6 2097.4
## - studytime:romantic 1 3763.9 2097.4
## - famsup:higher 1 3764.0 2097.4
## - failures:romantic 1 3764.3 2097.5
## - goout:health 1 3764.4 2097.5
## - sex:goout 1 3764.5 2097.5
## - famsup:health 1 3764.9 2097.5
## - famsup:romantic 1 3765.1 2097.6
## - sex:higher 1 3765.2 2097.6
## - sex:studytime 1 3765.3 2097.6
## - schoolsup:romantic 1 3766.2 2097.7
## - studytime:health 1 3766.6 2097.7
## - studytime:higher 1 3767.0 2097.7
## - failures:schoolsup 1 3769.1 2098.0
## - failures:health 1 3771.2 2098.2
## - higher:romantic 1 3772.1 2098.3
## - schoolsup:goout 1 3772.3 2098.3
## - schoolsup:famsup 1 3773.7 2098.4
## - studytime:failures 1 3773.7 2098.4
## - sex:romantic 1 3777.5 2098.8
## - sex:famsup 1 3779.4 2099.0
## <none> 3763.0 2099.3
## - sex:failures 1 3786.2 2099.8
## - sex:schoolsup 1 3786.3 2099.8
## - studytime:goout 1 3791.7 2100.3
## - higher:goout 1 3792.1 2100.4
## - failures:higher 1 3792.2 2100.4
## - schoolsup:health 1 3810.0 2102.2
## - failures:goout 1 3813.2 2102.6
## - studytime:famsup 1 3821.5 2103.4
## - studytime:schoolsup 1 3857.0 2107.1
##
## Step: AIC=2097.34
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +

14
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:higher + studytime:romantic + studytime:goout +
## studytime:health + failures:schoolsup + failures:higher +
## failures:romantic + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:higher + schoolsup:romantic + schoolsup:goout +
## schoolsup:health + famsup:higher + famsup:romantic + famsup:goout +
## famsup:health + higher:romantic + higher:goout + higher:health +
## goout:health
##
## Df Deviance AIC
## - famsup:goout 1 3763.4 2095.4
## - higher:health 1 3763.7 2095.4
## - schoolsup:higher 1 3763.7 2095.4
## - studytime:romantic 1 3764.0 2095.4
## - famsup:higher 1 3764.0 2095.4
## - failures:romantic 1 3764.4 2095.5
## - goout:health 1 3764.6 2095.5
## - sex:goout 1 3764.8 2095.5
## - famsup:health 1 3765.2 2095.6
## - sex:higher 1 3765.4 2095.6
## - famsup:romantic 1 3765.4 2095.6
## - sex:studytime 1 3765.5 2095.6
## - schoolsup:romantic 1 3766.2 2095.7
## - studytime:health 1 3766.8 2095.7
## - studytime:higher 1 3767.2 2095.8
## - failures:schoolsup 1 3769.4 2096.0
## - failures:health 1 3771.9 2096.3
## - higher:romantic 1 3772.1 2096.3
## - schoolsup:goout 1 3772.7 2096.3
## - schoolsup:famsup 1 3774.0 2096.5
## - studytime:failures 1 3774.1 2096.5
## - sex:romantic 1 3777.5 2096.8
## - sex:famsup 1 3779.7 2097.1
## <none> 3763.1 2097.3
## - sex:failures 1 3786.4 2097.8
## - sex:schoolsup 1 3786.6 2097.8
## - studytime:goout 1 3791.7 2098.3
## - higher:goout 1 3792.1 2098.4
## - failures:higher 1 3792.4 2098.4
## - schoolsup:health 1 3810.8 2100.3
## - failures:goout 1 3813.6 2100.6
## - studytime:famsup 1 3823.1 2101.6
## - studytime:schoolsup 1 3859.8 2105.4
##
## Step: AIC=2095.36
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:higher + studytime:romantic + studytime:goout +
## studytime:health + failures:schoolsup + failures:higher +
## failures:romantic + failures:goout + failures:health + schoolsup:famsup +

15
## schoolsup:higher + schoolsup:romantic + schoolsup:goout +
## schoolsup:health + famsup:higher + famsup:romantic + famsup:health +
## higher:romantic + higher:goout + higher:health + goout:health
##
## Df Deviance AIC
## - schoolsup:higher 1 3763.9 2093.4
## - higher:health 1 3764.0 2093.4
## - famsup:higher 1 3764.2 2093.4
## - studytime:romantic 1 3764.4 2093.5
## - failures:romantic 1 3764.7 2093.5
## - goout:health 1 3764.9 2093.5
## - sex:goout 1 3765.2 2093.6
## - famsup:health 1 3765.5 2093.6
## - sex:higher 1 3765.5 2093.6
## - famsup:romantic 1 3765.7 2093.6
## - sex:studytime 1 3765.7 2093.6
## - schoolsup:romantic 1 3766.5 2093.7
## - studytime:health 1 3767.2 2093.8
## - studytime:higher 1 3767.3 2093.8
## - failures:schoolsup 1 3769.8 2094.0
## - failures:health 1 3772.0 2094.3
## - higher:romantic 1 3772.1 2094.3
## - schoolsup:goout 1 3772.7 2094.3
## - schoolsup:famsup 1 3774.2 2094.5
## - studytime:failures 1 3774.3 2094.5
## - sex:romantic 1 3777.8 2094.9
## - sex:famsup 1 3780.1 2095.1
## <none> 3763.4 2095.4
## - sex:failures 1 3786.4 2095.8
## - sex:schoolsup 1 3787.1 2095.8
## - studytime:goout 1 3791.8 2096.3
## - failures:higher 1 3792.5 2096.4
## - higher:goout 1 3792.6 2096.4
## - schoolsup:health 1 3811.1 2098.3
## - failures:goout 1 3813.6 2098.6
## - studytime:famsup 1 3823.2 2099.6
## - studytime:schoolsup 1 3859.8 2103.4
##
## Step: AIC=2093.42
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:higher + studytime:romantic + studytime:goout +
## studytime:health + failures:schoolsup + failures:higher +
## failures:romantic + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:romantic + schoolsup:goout + schoolsup:health +
## famsup:higher + famsup:romantic + famsup:health + higher:romantic +
## higher:goout + higher:health + goout:health
##
## Df Deviance AIC
## - higher:health 1 3764.6 2091.5
## - studytime:romantic 1 3764.9 2091.5
## - famsup:higher 1 3765.0 2091.5

16
## - failures:romantic 1 3765.2 2091.6
## - goout:health 1 3765.4 2091.6
## - sex:goout 1 3766.0 2091.6
## - famsup:health 1 3766.0 2091.6
## - sex:studytime 1 3766.2 2091.7
## - sex:higher 1 3766.3 2091.7
## - famsup:romantic 1 3766.3 2091.7
## - schoolsup:romantic 1 3766.7 2091.7
## - studytime:health 1 3767.8 2091.8
## - studytime:higher 1 3767.9 2091.8
## - failures:health 1 3772.8 2092.3
## - failures:schoolsup 1 3774.1 2092.5
## - higher:romantic 1 3774.1 2092.5
## - schoolsup:famsup 1 3774.3 2092.5
## - studytime:failures 1 3774.4 2092.5
## - schoolsup:goout 1 3774.5 2092.5
## - sex:romantic 1 3777.9 2092.9
## - sex:famsup 1 3780.6 2093.2
## <none> 3763.9 2093.4
## - sex:failures 1 3786.4 2093.8
## - sex:schoolsup 1 3787.1 2093.8
## - studytime:goout 1 3792.5 2094.4
## - higher:goout 1 3798.2 2095.0
## - failures:higher 1 3798.4 2095.0
## - schoolsup:health 1 3811.3 2096.4
## - failures:goout 1 3814.3 2096.7
## - studytime:famsup 1 3823.6 2097.6
## - studytime:schoolsup 1 3864.5 2101.8
##
## Step: AIC=2091.49
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:higher + studytime:romantic + studytime:goout +
## studytime:health + failures:schoolsup + failures:higher +
## failures:romantic + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:romantic + schoolsup:goout + schoolsup:health +
## famsup:higher + famsup:romantic + famsup:health + higher:romantic +
## higher:goout + goout:health
##
## Df Deviance AIC
## - studytime:romantic 1 3765.6 2089.6
## - failures:romantic 1 3765.7 2089.6
## - goout:health 1 3766.0 2089.7
## - famsup:higher 1 3766.1 2089.7
## - famsup:health 1 3766.4 2089.7
## - sex:goout 1 3766.5 2089.7
## - sex:studytime 1 3766.9 2089.7
## - sex:higher 1 3767.0 2089.7
## - famsup:romantic 1 3767.1 2089.8
## - schoolsup:romantic 1 3767.4 2089.8
## - studytime:health 1 3768.1 2089.9
## - studytime:higher 1 3768.5 2089.9

17
## - studytime:failures 1 3774.6 2090.5
## - failures:schoolsup 1 3775.1 2090.6
## - schoolsup:goout 1 3775.2 2090.6
## - schoolsup:famsup 1 3775.2 2090.6
## - higher:romantic 1 3775.3 2090.6
## - failures:health 1 3776.8 2090.8
## - sex:romantic 1 3778.6 2091.0
## - sex:famsup 1 3780.8 2091.2
## <none> 3764.6 2091.5
## - sex:failures 1 3786.9 2091.8
## - sex:schoolsup 1 3787.8 2091.9
## - studytime:goout 1 3793.0 2092.5
## - failures:higher 1 3798.4 2093.0
## - higher:goout 1 3798.7 2093.1
## - schoolsup:health 1 3812.7 2094.5
## - failures:goout 1 3816.3 2094.9
## - studytime:famsup 1 3824.4 2095.7
## - studytime:schoolsup 1 3865.6 2099.9
##
## Step: AIC=2089.6
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:higher + studytime:goout + studytime:health + failures:schoolsup +
## failures:higher + failures:romantic + failures:goout + failures:health +
## schoolsup:famsup + schoolsup:romantic + schoolsup:goout +
## schoolsup:health + famsup:higher + famsup:romantic + famsup:health +
## higher:romantic + higher:goout + goout:health
##
## Df Deviance AIC
## - failures:romantic 1 3767.1 2087.8
## - famsup:higher 1 3767.2 2087.8
## - famsup:health 1 3767.4 2087.8
## - goout:health 1 3767.5 2087.8
## - sex:goout 1 3767.6 2087.8
## - sex:higher 1 3767.9 2087.8
## - schoolsup:romantic 1 3767.9 2087.8
## - famsup:romantic 1 3768.0 2087.9
## - sex:studytime 1 3768.3 2087.9
## - studytime:health 1 3769.4 2088.0
## - studytime:higher 1 3769.5 2088.0
## - schoolsup:goout 1 3776.1 2088.7
## - schoolsup:famsup 1 3776.2 2088.7
## - failures:schoolsup 1 3776.4 2088.7
## - studytime:failures 1 3776.7 2088.8
## - failures:health 1 3777.3 2088.8
## - higher:romantic 1 3777.7 2088.9
## - sex:romantic 1 3778.7 2089.0
## - sex:famsup 1 3782.1 2089.3
## <none> 3765.6 2089.6
## - sex:failures 1 3787.6 2089.9
## - sex:schoolsup 1 3788.8 2090.0
## - studytime:goout 1 3793.7 2090.5

18
## - failures:higher 1 3799.4 2091.1
## - higher:goout 1 3799.5 2091.1
## - schoolsup:health 1 3813.7 2092.6
## - failures:goout 1 3818.3 2093.1
## - studytime:famsup 1 3826.6 2093.9
## - studytime:schoolsup 1 3873.9 2098.8
##
## Step: AIC=2087.75
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:higher + studytime:goout + studytime:health + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:romantic + schoolsup:goout + schoolsup:health +
## famsup:higher + famsup:romantic + famsup:health + higher:romantic +
## higher:goout + goout:health
##
## Df Deviance AIC
## - famsup:health 1 3768.8 2085.9
## - sex:higher 1 3768.9 2085.9
## - famsup:higher 1 3768.9 2085.9
## - goout:health 1 3768.9 2085.9
## - schoolsup:romantic 1 3769.2 2086.0
## - sex:goout 1 3769.2 2086.0
## - famsup:romantic 1 3769.3 2086.0
## - sex:studytime 1 3769.7 2086.0
## - studytime:health 1 3771.1 2086.2
## - studytime:higher 1 3771.2 2086.2
## - studytime:failures 1 3776.7 2086.8
## - failures:schoolsup 1 3778.2 2086.9
## - schoolsup:famsup 1 3778.3 2086.9
## - failures:health 1 3778.7 2087.0
## - schoolsup:goout 1 3778.8 2087.0
## - sex:romantic 1 3781.2 2087.2
## - sex:famsup 1 3783.2 2087.4
## - higher:romantic 1 3785.4 2087.7
## <none> 3767.1 2087.8
## - sex:failures 1 3787.8 2087.9
## - sex:schoolsup 1 3791.5 2088.3
## - studytime:goout 1 3796.3 2088.8
## - failures:higher 1 3800.1 2089.2
## - higher:goout 1 3802.9 2089.5
## - schoolsup:health 1 3814.1 2090.7
## - failures:goout 1 3818.4 2091.1
## - studytime:famsup 1 3827.4 2092.0
## - studytime:schoolsup 1 3876.3 2097.0
##
## Step: AIC=2085.93
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:higher + studytime:goout + studytime:health + failures:schoolsup +

19
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:romantic + schoolsup:goout + schoolsup:health +
## famsup:higher + famsup:romantic + higher:romantic + higher:goout +
## goout:health
##
## Df Deviance AIC
## - goout:health 1 3770.4 2084.1
## - sex:higher 1 3770.5 2084.1
## - famsup:higher 1 3770.6 2084.1
## - schoolsup:romantic 1 3770.6 2084.1
## - sex:goout 1 3770.8 2084.1
## - famsup:romantic 1 3771.4 2084.2
## - sex:studytime 1 3771.8 2084.2
## - studytime:higher 1 3773.1 2084.4
## - studytime:health 1 3773.9 2084.5
## - studytime:failures 1 3778.7 2085.0
## - failures:health 1 3779.8 2085.1
## - schoolsup:famsup 1 3780.0 2085.1
## - schoolsup:goout 1 3780.4 2085.2
## - failures:schoolsup 1 3780.4 2085.2
## - sex:famsup 1 3783.8 2085.5
## - sex:romantic 1 3784.7 2085.6
## - higher:romantic 1 3787.3 2085.9
## <none> 3768.8 2085.9
## - sex:failures 1 3789.2 2086.1
## - sex:schoolsup 1 3792.2 2086.4
## - studytime:goout 1 3796.6 2086.8
## - failures:higher 1 3801.0 2087.3
## - higher:goout 1 3804.2 2087.6
## - schoolsup:health 1 3816.2 2088.9
## - failures:goout 1 3819.5 2089.2
## - studytime:famsup 1 3831.0 2090.4
## - studytime:schoolsup 1 3877.2 2095.1
##
## Step: AIC=2084.1
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:higher + studytime:goout + studytime:health + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:romantic + schoolsup:goout + schoolsup:health +
## famsup:higher + famsup:romantic + higher:romantic + higher:goout
##
## Df Deviance AIC
## - famsup:higher 1 3772.0 2082.3
## - sex:higher 1 3772.1 2082.3
## - schoolsup:romantic 1 3772.4 2082.3
## - famsup:romantic 1 3772.8 2082.3
## - sex:goout 1 3772.8 2082.3
## - sex:studytime 1 3773.0 2082.4
## - studytime:higher 1 3774.8 2082.6
## - studytime:health 1 3775.8 2082.7
## - studytime:failures 1 3780.1 2083.1

20
## - schoolsup:goout 1 3781.3 2083.2
## - schoolsup:famsup 1 3781.5 2083.3
## - failures:schoolsup 1 3781.6 2083.3
## - failures:health 1 3783.5 2083.5
## - sex:famsup 1 3786.8 2083.8
## - sex:romantic 1 3787.0 2083.8
## - higher:romantic 1 3788.2 2084.0
## <none> 3770.4 2084.1
## - sex:failures 1 3791.4 2084.3
## - sex:schoolsup 1 3793.3 2084.5
## - studytime:goout 1 3797.9 2085.0
## - failures:higher 1 3804.2 2085.6
## - higher:goout 1 3806.4 2085.9
## - schoolsup:health 1 3819.1 2087.2
## - failures:goout 1 3820.5 2087.3
## - studytime:famsup 1 3836.2 2088.9
## - studytime:schoolsup 1 3877.2 2093.1
##
## Step: AIC=2082.27
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:higher + sex:romantic +
## sex:goout + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:higher + studytime:goout + studytime:health + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:romantic + schoolsup:goout + schoolsup:health +
## famsup:romantic + higher:romantic + higher:goout
##
## Df Deviance AIC
## - sex:higher 1 3772.8 2080.4
## - famsup:romantic 1 3773.8 2080.5
## - schoolsup:romantic 1 3773.9 2080.5
## - sex:studytime 1 3774.9 2080.6
## - sex:goout 1 3775.0 2080.6
## - studytime:higher 1 3775.4 2080.6
## - studytime:health 1 3777.5 2080.8
## - studytime:failures 1 3781.8 2081.3
## - schoolsup:famsup 1 3783.3 2081.4
## - schoolsup:goout 1 3783.3 2081.4
## - failures:schoolsup 1 3783.8 2081.5
## - failures:health 1 3784.9 2081.6
## - sex:romantic 1 3788.8 2082.0
## - sex:famsup 1 3789.2 2082.1
## - higher:romantic 1 3789.3 2082.1
## <none> 3772.0 2082.3
## - sex:failures 1 3793.1 2082.5
## - sex:schoolsup 1 3794.9 2082.7
## - studytime:goout 1 3799.3 2083.1
## - failures:higher 1 3806.9 2083.9
## - higher:goout 1 3812.8 2084.5
## - schoolsup:health 1 3820.7 2085.3
## - failures:goout 1 3820.9 2085.3
## - studytime:famsup 1 3836.2 2086.9
## - studytime:schoolsup 1 3878.8 2091.3

21
##
## Step: AIC=2080.36
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:romantic + sex:goout + studytime:failures +
## studytime:schoolsup + studytime:famsup + studytime:higher +
## studytime:goout + studytime:health + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:romantic + schoolsup:goout + schoolsup:health +
## famsup:romantic + higher:romantic + higher:goout
##
## Df Deviance AIC
## - schoolsup:romantic 1 3774.6 2078.5
## - famsup:romantic 1 3774.7 2078.6
## - studytime:higher 1 3775.6 2078.7
## - sex:studytime 1 3775.7 2078.7
## - sex:goout 1 3775.8 2078.7
## - studytime:health 1 3778.2 2078.9
## - studytime:failures 1 3783.7 2079.5
## - schoolsup:famsup 1 3784.1 2079.5
## - schoolsup:goout 1 3784.1 2079.5
## - failures:schoolsup 1 3784.8 2079.6
## - failures:health 1 3785.6 2079.7
## - sex:famsup 1 3789.7 2080.1
## - sex:romantic 1 3790.3 2080.2
## <none> 3772.8 2080.4
## - sex:failures 1 3793.1 2080.5
## - sex:schoolsup 1 3795.9 2080.8
## - higher:romantic 1 3795.9 2080.8
## - studytime:goout 1 3799.4 2081.1
## - failures:higher 1 3808.1 2082.0
## - higher:goout 1 3815.2 2082.8
## - schoolsup:health 1 3821.9 2083.5
## - failures:goout 1 3822.6 2083.5
## - studytime:famsup 1 3836.4 2084.9
## - studytime:schoolsup 1 3879.7 2089.4
##
## Step: AIC=2078.54
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:romantic + sex:goout + studytime:failures +
## studytime:schoolsup + studytime:famsup + studytime:higher +
## studytime:goout + studytime:health + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:goout + schoolsup:health + famsup:romantic + higher:romantic +
## higher:goout
##
## Df Deviance AIC
## - famsup:romantic 1 3776.1 2076.7
## - sex:studytime 1 3777.4 2076.8
## - studytime:higher 1 3777.4 2076.8
## - sex:goout 1 3777.6 2076.9
## - studytime:health 1 3779.9 2077.1
## - schoolsup:famsup 1 3785.0 2077.6

22
## - schoolsup:goout 1 3785.1 2077.6
## - studytime:failures 1 3785.7 2077.7
## - failures:health 1 3786.9 2077.8
## - failures:schoolsup 1 3787.8 2077.9
## - sex:romantic 1 3791.5 2078.3
## - sex:famsup 1 3791.7 2078.3
## <none> 3774.6 2078.5
## - sex:failures 1 3794.6 2078.6
## - sex:schoolsup 1 3797.9 2079.0
## - higher:romantic 1 3798.4 2079.0
## - studytime:goout 1 3801.0 2079.3
## - failures:higher 1 3809.4 2080.2
## - higher:goout 1 3816.6 2080.9
## - schoolsup:health 1 3823.6 2081.6
## - failures:goout 1 3827.3 2082.0
## - studytime:famsup 1 3838.3 2083.2
## - studytime:schoolsup 1 3890.5 2088.5
##
## Step: AIC=2076.7
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:studytime + sex:failures +
## sex:schoolsup + sex:famsup + sex:romantic + sex:goout + studytime:failures +
## studytime:schoolsup + studytime:famsup + studytime:higher +
## studytime:goout + studytime:health + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:goout + schoolsup:health + higher:romantic + higher:goout
##
## Df Deviance AIC
## - sex:studytime 1 3778.9 2075.0
## - studytime:higher 1 3779.0 2075.0
## - sex:goout 1 3779.3 2075.0
## - studytime:health 1 3781.8 2075.3
## - schoolsup:famsup 1 3785.7 2075.7
## - schoolsup:goout 1 3786.8 2075.8
## - studytime:failures 1 3786.9 2075.8
## - failures:schoolsup 1 3788.5 2076.0
## - failures:health 1 3789.4 2076.1
## - sex:romantic 1 3793.8 2076.6
## - sex:famsup 1 3795.2 2076.7
## <none> 3776.1 2076.7
## - sex:failures 1 3797.0 2076.9
## - higher:romantic 1 3799.4 2077.1
## - sex:schoolsup 1 3799.9 2077.2
## - studytime:goout 1 3803.7 2077.6
## - failures:higher 1 3813.9 2078.6
## - higher:goout 1 3820.0 2079.3
## - schoolsup:health 1 3823.8 2079.7
## - failures:goout 1 3831.0 2080.4
## - studytime:famsup 1 3839.0 2081.2
## - studytime:schoolsup 1 3892.3 2086.7
##
## Step: AIC=2074.99
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:failures + sex:schoolsup +

23
## sex:famsup + sex:romantic + sex:goout + studytime:failures +
## studytime:schoolsup + studytime:famsup + studytime:higher +
## studytime:goout + studytime:health + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:goout + schoolsup:health + higher:romantic + higher:goout
##
## Df Deviance AIC
## - studytime:higher 1 3781.0 2073.2
## - sex:goout 1 3782.3 2073.3
## - studytime:health 1 3785.6 2073.7
## - schoolsup:famsup 1 3788.3 2074.0
## - schoolsup:goout 1 3789.5 2074.1
## - studytime:failures 1 3791.0 2074.2
## - failures:schoolsup 1 3791.1 2074.3
## - failures:health 1 3792.4 2074.4
## - sex:romantic 1 3795.9 2074.8
## - sex:famsup 1 3797.6 2074.9
## - sex:failures 1 3797.8 2075.0
## <none> 3778.9 2075.0
## - sex:schoolsup 1 3802.0 2075.4
## - higher:romantic 1 3802.2 2075.4
## - studytime:goout 1 3808.9 2076.1
## - failures:higher 1 3816.0 2076.8
## - higher:goout 1 3823.8 2077.7
## - schoolsup:health 1 3825.7 2077.8
## - failures:goout 1 3833.4 2078.7
## - studytime:famsup 1 3848.3 2080.2
## - studytime:schoolsup 1 3893.1 2084.8
##
## Step: AIC=2073.21
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:failures + sex:schoolsup +
## sex:famsup + sex:romantic + sex:goout + studytime:failures +
## studytime:schoolsup + studytime:famsup + studytime:goout +
## studytime:health + failures:schoolsup + failures:higher +
## failures:goout + failures:health + schoolsup:famsup + schoolsup:goout +
## schoolsup:health + higher:romantic + higher:goout
##
## Df Deviance AIC
## - sex:goout 1 3783.8 2071.5
## - studytime:health 1 3787.4 2071.9
## - schoolsup:famsup 1 3790.5 2072.2
## - schoolsup:goout 1 3791.4 2072.3
## - failures:schoolsup 1 3792.7 2072.4
## - failures:health 1 3793.1 2072.5
## - studytime:failures 1 3796.3 2072.8
## - sex:romantic 1 3797.0 2072.9
## - sex:famsup 1 3798.8 2073.1
## - sex:failures 1 3799.9 2073.2
## <none> 3781.0 2073.2
## - sex:schoolsup 1 3803.8 2073.6
## - higher:romantic 1 3805.0 2073.7
## - studytime:goout 1 3809.9 2074.2
## - failures:higher 1 3816.8 2074.9

24
## - higher:goout 1 3826.8 2076.0
## - schoolsup:health 1 3827.7 2076.1
## - failures:goout 1 3837.9 2077.1
## - studytime:famsup 1 3848.8 2078.2
## - studytime:schoolsup 1 3894.9 2082.9
##
## Step: AIC=2071.5
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:failures + sex:schoolsup +
## sex:famsup + sex:romantic + studytime:failures + studytime:schoolsup +
## studytime:famsup + studytime:goout + studytime:health + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:goout + schoolsup:health + higher:romantic + higher:goout
##
## Df Deviance AIC
## - studytime:health 1 3789.6 2070.1
## - schoolsup:famsup 1 3792.5 2070.4
## - schoolsup:goout 1 3793.1 2070.5
## - failures:health 1 3796.3 2070.8
## - failures:schoolsup 1 3796.6 2070.8
## - studytime:failures 1 3798.5 2071.0
## - sex:romantic 1 3799.4 2071.1
## - sex:famsup 1 3801.3 2071.3
## <none> 3783.8 2071.5
## - sex:failures 1 3805.3 2071.7
## - sex:schoolsup 1 3806.0 2071.8
## - higher:romantic 1 3807.7 2072.0
## - studytime:goout 1 3810.1 2072.2
## - failures:higher 1 3821.2 2073.4
## - schoolsup:health 1 3831.0 2074.4
## - higher:goout 1 3832.0 2074.5
## - failures:goout 1 3843.7 2075.7
## - studytime:famsup 1 3850.3 2076.4
## - studytime:schoolsup 1 3896.0 2081.0
##
## Step: AIC=2070.1
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:failures + sex:schoolsup +
## sex:famsup + sex:romantic + studytime:failures + studytime:schoolsup +
## studytime:famsup + studytime:goout + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:goout + schoolsup:health + higher:romantic + higher:goout
##
## Df Deviance AIC
## - schoolsup:goout 1 3797.5 2068.9
## - schoolsup:famsup 1 3797.6 2068.9
## - failures:health 1 3799.7 2069.2
## - studytime:failures 1 3803.9 2069.6
## - sex:romantic 1 3803.9 2069.6
## - failures:schoolsup 1 3804.1 2069.6
## - sex:famsup 1 3805.0 2069.7
## <none> 3789.6 2070.1
## - sex:failures 1 3810.8 2070.3
## - sex:schoolsup 1 3812.7 2070.5

25
## - higher:romantic 1 3812.7 2070.5
## - studytime:goout 1 3816.4 2070.9
## - failures:higher 1 3826.2 2071.9
## - schoolsup:health 1 3834.2 2072.7
## - higher:goout 1 3836.8 2073.0
## - failures:goout 1 3850.1 2074.4
## - studytime:famsup 1 3851.7 2074.5
## - studytime:schoolsup 1 3899.7 2079.4
##
## Step: AIC=2068.93
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:failures + sex:schoolsup +
## sex:famsup + sex:romantic + studytime:failures + studytime:schoolsup +
## studytime:famsup + studytime:goout + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:famsup +
## schoolsup:health + higher:romantic + higher:goout
##
## Df Deviance AIC
## - schoolsup:famsup 1 3805.4 2067.8
## - failures:health 1 3808.0 2068.0
## - studytime:failures 1 3811.0 2068.3
## - sex:romantic 1 3812.0 2068.4
## - failures:schoolsup 1 3814.3 2068.7
## - sex:famsup 1 3814.8 2068.7
## <none> 3797.5 2068.9
## - sex:failures 1 3818.1 2069.1
## - sex:schoolsup 1 3819.7 2069.2
## - studytime:goout 1 3822.1 2069.5
## - higher:romantic 1 3822.8 2069.6
## - failures:higher 1 3835.8 2070.9
## - schoolsup:health 1 3840.4 2071.4
## - higher:goout 1 3843.3 2071.7
## - studytime:famsup 1 3859.8 2073.4
## - failures:goout 1 3860.0 2073.4
## - studytime:schoolsup 1 3902.4 2077.7
##
## Step: AIC=2067.75
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:failures + sex:schoolsup +
## sex:famsup + sex:romantic + studytime:failures + studytime:schoolsup +
## studytime:famsup + studytime:goout + failures:schoolsup +
## failures:higher + failures:goout + failures:health + schoolsup:health +
## higher:romantic + higher:goout
##
## Df Deviance AIC
## - failures:health 1 3815.0 2066.7
## - studytime:failures 1 3817.2 2067.0
## - sex:romantic 1 3819.6 2067.2
## - failures:schoolsup 1 3823.0 2067.6
## <none> 3805.4 2067.8
## - sex:famsup 1 3827.1 2068.0
## - sex:failures 1 3827.6 2068.1
## - higher:romantic 1 3828.9 2068.2
## - sex:schoolsup 1 3829.6 2068.2

26
## - studytime:goout 1 3830.7 2068.4
## - failures:higher 1 3842.4 2069.6
## - schoolsup:health 1 3845.2 2069.9
## - higher:goout 1 3849.0 2070.2
## - failures:goout 1 3864.7 2071.9
## - studytime:famsup 1 3867.1 2072.1
## - studytime:schoolsup 1 3910.8 2076.5
##
## Step: AIC=2066.74
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:failures + sex:schoolsup +
## sex:famsup + sex:romantic + studytime:failures + studytime:schoolsup +
## studytime:famsup + studytime:goout + failures:schoolsup +
## failures:higher + failures:goout + schoolsup:health + higher:romantic +
## higher:goout
##
## Df Deviance AIC
## - sex:romantic 1 3828.0 2066.1
## - studytime:failures 1 3828.3 2066.1
## <none> 3815.0 2066.7
## - sex:failures 1 3835.4 2066.8
## - failures:schoolsup 1 3836.0 2066.9
## - higher:romantic 1 3836.5 2067.0
## - sex:famsup 1 3836.6 2067.0
## - sex:schoolsup 1 3838.4 2067.2
## - studytime:goout 1 3839.0 2067.2
## - failures:higher 1 3850.9 2068.4
## - higher:goout 1 3855.1 2068.9
## - schoolsup:health 1 3856.7 2069.1
## - failures:goout 1 3871.3 2070.5
## - studytime:famsup 1 3878.0 2071.2
## - studytime:schoolsup 1 3917.4 2075.2
##
## Step: AIC=2066.09
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:failures + sex:schoolsup +
## sex:famsup + studytime:failures + studytime:schoolsup + studytime:famsup +
## studytime:goout + failures:schoolsup + failures:higher +
## failures:goout + schoolsup:health + higher:romantic + higher:goout
##
## Df Deviance AIC
## - studytime:failures 1 3840.4 2065.4
## - higher:romantic 1 3844.9 2065.8
## <none> 3828.0 2066.1
## - sex:failures 1 3848.7 2066.2
## - sex:famsup 1 3850.2 2066.4
## - failures:schoolsup 1 3850.6 2066.4
## - studytime:goout 1 3851.8 2066.5
## - sex:schoolsup 1 3853.7 2066.7
## - higher:goout 1 3867.0 2068.1
## - schoolsup:health 1 3867.1 2068.1
## - failures:higher 1 3871.4 2068.5
## - failures:goout 1 3883.8 2069.8
## - studytime:famsup 1 3890.9 2070.5

27
## - studytime:schoolsup 1 3927.3 2074.2
##
## Step: AIC=2065.36
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:failures + sex:schoolsup +
## sex:famsup + studytime:schoolsup + studytime:famsup + studytime:goout +
## failures:schoolsup + failures:higher + failures:goout + schoolsup:health +
## higher:romantic + higher:goout
##
## Df Deviance AIC
## - higher:romantic 1 3857.0 2065.1
## <none> 3840.4 2065.4
## - failures:schoolsup 1 3863.2 2065.7
## - sex:famsup 1 3863.5 2065.7
## - studytime:goout 1 3865.0 2065.9
## - sex:schoolsup 1 3866.7 2066.1
## - higher:goout 1 3874.7 2066.9
## - schoolsup:health 1 3876.5 2067.1
## - failures:higher 1 3878.7 2067.3
## - sex:failures 1 3886.7 2068.1
## - failures:goout 1 3888.8 2068.3
## - studytime:famsup 1 3906.2 2070.1
## - studytime:schoolsup 1 3940.3 2073.5
##
## Step: AIC=2065.07
## (G1 + G2 + G3)/3 ~ sex + studytime + failures + schoolsup + famsup +
## higher + romantic + goout + health + sex:failures + sex:schoolsup +
## sex:famsup + studytime:schoolsup + studytime:famsup + studytime:goout +
## failures:schoolsup + failures:higher + failures:goout + schoolsup:health +
## higher:goout
##
## Df Deviance AIC
## <none> 3857.0 2065.1
## - sex:famsup 1 3878.9 2065.3
## - sex:schoolsup 1 3881.4 2065.6
## - studytime:goout 1 3882.0 2065.6
## - romantic 1 3882.7 2065.7
## - failures:schoolsup 1 3883.7 2065.8
## - higher:goout 1 3885.8 2066.0
## - failures:higher 1 3891.9 2066.6
## - schoolsup:health 1 3892.7 2066.7
## - failures:goout 1 3895.4 2067.0
## - sex:failures 1 3906.9 2068.2
## - studytime:famsup 1 3920.8 2069.6
## - studytime:schoolsup 1 3961.7 2073.7
#BIC
#fit2_step <- step(fit2, k = log(395))
summary(fit2_step)

##
## Call:
## glm(formula = (G1 + G2 + G3)/3 ~ sex + studytime + failures +
## schoolsup + famsup + higher + romantic + goout + health +
## sex:failures + sex:schoolsup + sex:famsup + studytime:schoolsup +

28
## studytime:famsup + studytime:goout + failures:schoolsup +
## failures:higher + failures:goout + schoolsup:health + higher:goout,
## data = data)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -10.2505 -2.0602 0.1947 2.2163 9.3797
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 12.8122 2.4090 5.318 1.8e-07 ***
## sexM 0.8937 0.6070 1.472 0.14180
## studytime 0.9013 0.6483 1.390 0.16525
## failures -1.3795 0.9120 -1.513 0.13122
## schoolsupyes 0.5583 2.0239 0.276 0.78280
## famsupyes -3.2079 1.0928 -2.936 0.00354 **
## higheryes -0.4758 2.0072 -0.237 0.81275
## romanticyes -0.5621 0.3561 -1.578 0.11534
## goout -0.8522 0.6402 -1.331 0.18397
## health -0.2934 0.1277 -2.298 0.02210 *
## sexM:failures -1.1131 0.5057 -2.201 0.02832 *
## sexM:schoolsupyes -1.7002 1.1036 -1.541 0.12427
## sexM:famsupyes 1.0596 0.7267 1.458 0.14564
## studytime:schoolsupyes -1.9808 0.6214 -3.188 0.00156 **
## studytime:famsupyes 1.0856 0.4365 2.487 0.01331 *
## studytime:goout -0.2868 0.1841 -1.558 0.12006
## failures:schoolsupyes 1.1308 0.7021 1.610 0.10813
## failures:higheryes -1.2526 0.6801 -1.842 0.06630 .
## failures:goout 0.3811 0.1974 1.930 0.05431 .
## schoolsupyes:health 0.6725 0.3614 1.861 0.06358 .
## higheryes:goout 0.9389 0.5613 1.673 0.09524 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 10.31273)
##
## Null deviance: 5384.5 on 394 degrees of freedom
## Residual deviance: 3857.0 on 374 degrees of freedom
## AIC: 2065.1
##
## Number of Fisher Scoring iterations: 2
fit3 <- glm(formula = (G1 + G2 + G3)/3 ~ sex + studytime + failures +
schoolsup + famsup + higher + romantic + goout + health +
sex:failures + sex:schoolsup + sex:famsup + studytime:schoolsup +
studytime:famsup + studytime:goout + failures:schoolsup +
failures:higher + failures:goout + schoolsup:health + higher:goout,
data = data)
summary(fit3)

##
## Call:
## glm(formula = (G1 + G2 + G3)/3 ~ sex + studytime + failures +
## schoolsup + famsup + higher + romantic + goout + health +
## sex:failures + sex:schoolsup + sex:famsup + studytime:schoolsup +

29
## studytime:famsup + studytime:goout + failures:schoolsup +
## failures:higher + failures:goout + schoolsup:health + higher:goout,
## data = data)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -10.2505 -2.0602 0.1947 2.2163 9.3797
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 12.8122 2.4090 5.318 1.8e-07 ***
## sexM 0.8937 0.6070 1.472 0.14180
## studytime 0.9013 0.6483 1.390 0.16525
## failures -1.3795 0.9120 -1.513 0.13122
## schoolsupyes 0.5583 2.0239 0.276 0.78280
## famsupyes -3.2079 1.0928 -2.936 0.00354 **
## higheryes -0.4758 2.0072 -0.237 0.81275
## romanticyes -0.5621 0.3561 -1.578 0.11534
## goout -0.8522 0.6402 -1.331 0.18397
## health -0.2934 0.1277 -2.298 0.02210 *
## sexM:failures -1.1131 0.5057 -2.201 0.02832 *
## sexM:schoolsupyes -1.7002 1.1036 -1.541 0.12427
## sexM:famsupyes 1.0596 0.7267 1.458 0.14564
## studytime:schoolsupyes -1.9808 0.6214 -3.188 0.00156 **
## studytime:famsupyes 1.0856 0.4365 2.487 0.01331 *
## studytime:goout -0.2868 0.1841 -1.558 0.12006
## failures:schoolsupyes 1.1308 0.7021 1.610 0.10813
## failures:higheryes -1.2526 0.6801 -1.842 0.06630 .
## failures:goout 0.3811 0.1974 1.930 0.05431 .
## schoolsupyes:health 0.6725 0.3614 1.861 0.06358 .
## higheryes:goout 0.9389 0.5613 1.673 0.09524 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 10.31273)
##
## Null deviance: 5384.5 on 394 degrees of freedom
## Residual deviance: 3857.0 on 374 degrees of freedom
## AIC: 2065.1
##
## Number of Fisher Scoring iterations: 2
The goodnees-of-fit index are AIC:2065.1, which is better than before.
Diagnostics:
par(mfrow = c(2,2))
plot(fit3)

30
Std. deviance resid.
Residuals vs Fitted Normal Q−Q
10
199 199
Residuals

0 2
−10 0

333 243

−3
333
243

4 6 8 10 12 14 −3 −2 −1 0 1 2 3

Predicted values Theoretical Quantiles


Std. deviance resid.

Std. Pearson resid.


Scale−Location Residuals vs Leverage
199 333 243 0.5
1.0

0
141
149 distance
Cook's
260 0.5
0.0

−4
1

4 6 8 10 12 14 0.0 0.1 0.2 0.3 0.4 0.5

Predicted values Leverage


The first picture tells us the resudals are symmetrically around 0, and from second plot, we can see the
residuals follows normal distribution, from the third picture, we can see homogeneity of variance of residauls
is satisfied, and from the last picture, we can see there are some outliers.
Outliers:
Diagnostics <- data.frame(Id = 1:395, y = (data$G1 + data$G2 + data$G3)/3, cd = cooks.distance(fit3), le
dffit = dffits(fit3))
print(subset(Diagnostics, abs(r)>=2 | lev > 4/9| cd > 4/9 | abs(dffit)> 2*sqrt(1/9)))

## Id y cd lev r dffit
## 79 79 8.666667 0.018303161 0.55510660 0.5545108 0.6193986
## 135 135 3.000000 0.007190935 0.02036897 -2.7178528 -0.3919036
## 136 136 3.666667 0.005089414 0.02111600 -2.2377825 -0.3286685
## 137 137 3.333333 0.008954457 0.03000904 -2.4823538 -0.4366223
## 141 141 5.333333 0.022903560 0.22433900 -1.2907171 -0.6941406
## 149 149 4.333333 0.023504149 0.15214167 -1.6624212 -0.7042121
## 163 163 2.333333 0.007411473 0.02836029 -2.3227158 -0.3968248
## 199 199 18.000000 0.015639341 0.03579140 3.0063008 0.5792103
## 243 243 2.000000 0.022251983 0.04208486 -3.3042905 -0.6925923
## 245 245 2.333333 0.007164337 0.02197292 -2.6077816 -0.3908766
## 260 260 6.333333 0.038095122 0.11740062 -2.4690499 -0.9004990
## 261 261 17.666667 0.004647413 0.02154814 2.1148871 0.3138501
## 333 333 2.333333 0.008695776 0.02379702 -2.7611165 -0.4310980
## 374 374 5.333333 0.014554373 0.06329417 -2.1369139 -0.5554785
## 375 375 18.666667 0.009947319 0.04031746 2.2418411 0.4595022
## 377 377 14.666667 0.010575457 0.05159691 2.0288299 0.4732177
## 390 390 3.666667 0.009853000 0.04911707 -2.0095466 -0.4567208
Question 2
First we consider model without interaction variables.

31
library(leaps)
fit4 <- regsubsets((G1+G2+G3)/3 ~ ., data = data ,nvmax = 39, nbest = 1, really.big = T)
summary(fit4)

## Subset selection object


## Call: regsubsets.formula((G1 + G2 + G3)/3 ~ ., data = data, nvmax = 39,
## nbest = 1, really.big = T)
## 39 Variables (and intercept)
## Forced in Forced out
## schoolMS FALSE FALSE
## sexM FALSE FALSE
## age FALSE FALSE
## addressU FALSE FALSE
## famsizeLE3 FALSE FALSE
## PstatusT FALSE FALSE
## Medu FALSE FALSE
## Fedu FALSE FALSE
## Mjobhealth FALSE FALSE
## Mjobother FALSE FALSE
## Mjobservices FALSE FALSE
## Mjobteacher FALSE FALSE
## Fjobhealth FALSE FALSE
## Fjobother FALSE FALSE
## Fjobservices FALSE FALSE
## Fjobteacher FALSE FALSE
## reasonhome FALSE FALSE
## reasonother FALSE FALSE
## reasonreputation FALSE FALSE
## guardianmother FALSE FALSE
## guardianother FALSE FALSE
## traveltime FALSE FALSE
## studytime FALSE FALSE
## failures FALSE FALSE
## schoolsupyes FALSE FALSE
## famsupyes FALSE FALSE
## paidyes FALSE FALSE
## activitiesyes FALSE FALSE
## nurseryyes FALSE FALSE
## higheryes FALSE FALSE
## internetyes FALSE FALSE
## romanticyes FALSE FALSE
## famrel FALSE FALSE
## freetime FALSE FALSE
## goout FALSE FALSE
## Dalc FALSE FALSE
## Walc FALSE FALSE
## health FALSE FALSE
## absences FALSE FALSE
## 1 subsets of each size up to 39
## Selection Algorithm: exhaustive
## schoolMS sexM age addressU famsizeLE3 PstatusT Medu Fedu Mjobhealth
## 1 ( 1 ) " " " " " " " " " " " " " " " " " "
## 2 ( 1 ) " " " " " " " " " " " " "*" " " " "
## 3 ( 1 ) " " " " " " " " " " " " "*" " " " "

32
## 4 ( 1 ) " " " " " " " " " " " " " " " " "*"
## 5 ( 1 ) " " " " " " " " " " " " " " " " "*"
## 6 ( 1 ) " " "*" " " " " " " " " " " " " "*"
## 7 ( 1 ) " " "*" " " " " " " " " " " " " "*"
## 8 ( 1 ) " " "*" " " " " " " " " " " " " "*"
## 9 ( 1 ) " " "*" " " " " " " " " " " " " "*"
## 10 ( 1 ) " " "*" " " " " " " " " " " " " "*"
## 11 ( 1 ) " " "*" " " " " " " " " " " " " "*"
## 12 ( 1 ) " " "*" " " "*" " " " " " " " " "*"
## 13 ( 1 ) " " "*" " " "*" " " " " " " " " "*"
## 14 ( 1 ) " " "*" " " "*" " " " " " " " " "*"
## 15 ( 1 ) " " "*" " " "*" " " " " " " " " "*"
## 16 ( 1 ) " " "*" " " "*" "*" " " " " " " "*"
## 17 ( 1 ) " " "*" " " "*" "*" " " " " "*" "*"
## 18 ( 1 ) " " "*" "*" "*" "*" " " " " "*" "*"
## 19 ( 1 ) " " "*" "*" " " "*" " " "*" " " "*"
## 20 ( 1 ) " " "*" "*" "*" "*" " " "*" " " "*"
## 21 ( 1 ) " " "*" "*" " " "*" " " "*" " " "*"
## 22 ( 1 ) " " "*" "*" " " "*" " " "*" " " "*"
## 23 ( 1 ) " " "*" "*" " " "*" " " "*" " " "*"
## 24 ( 1 ) " " "*" "*" " " "*" " " "*" " " "*"
## 25 ( 1 ) " " "*" "*" "*" "*" " " "*" " " "*"
## 26 ( 1 ) " " "*" "*" "*" "*" " " "*" " " "*"
## 27 ( 1 ) " " "*" "*" "*" "*" " " "*" " " "*"
## 28 ( 1 ) "*" "*" "*" "*" "*" " " "*" " " "*"
## 29 ( 1 ) "*" "*" "*" "*" "*" " " "*" " " "*"
## 30 ( 1 ) "*" "*" "*" "*" "*" " " "*" " " "*"
## 31 ( 1 ) "*" "*" "*" "*" "*" " " "*" " " "*"
## 32 ( 1 ) "*" "*" "*" "*" "*" " " "*" " " "*"
## 33 ( 1 ) "*" "*" "*" "*" "*" " " "*" " " "*"
## 34 ( 1 ) "*" "*" "*" "*" "*" "*" "*" " " "*"
## 35 ( 1 ) "*" "*" "*" "*" "*" "*" "*" " " "*"
## 36 ( 1 ) "*" "*" "*" "*" "*" "*" "*" " " "*"
## 37 ( 1 ) "*" "*" "*" "*" "*" "*" "*" "*" "*"
## 38 ( 1 ) "*" "*" "*" "*" "*" "*" "*" "*" "*"
## 39 ( 1 ) "*" "*" "*" "*" "*" "*" "*" "*" "*"
## Mjobother Mjobservices Mjobteacher Fjobhealth Fjobother Fjobservices
## 1 ( 1 ) " " " " " " " " " " " "
## 2 ( 1 ) " " " " " " " " " " " "
## 3 ( 1 ) " " " " " " " " " " " "
## 4 ( 1 ) " " "*" " " " " " " " "
## 5 ( 1 ) " " "*" " " " " " " " "
## 6 ( 1 ) " " "*" " " " " " " " "
## 7 ( 1 ) " " "*" " " " " " " " "
## 8 ( 1 ) " " "*" " " " " " " " "
## 9 ( 1 ) " " "*" " " " " " " " "
## 10 ( 1 ) " " "*" " " " " " " " "
## 11 ( 1 ) " " "*" " " " " " " " "
## 12 ( 1 ) " " "*" " " " " " " " "
## 13 ( 1 ) " " "*" " " " " " " " "
## 14 ( 1 ) " " "*" " " " " " " " "
## 15 ( 1 ) " " "*" " " " " " " " "
## 16 ( 1 ) " " "*" " " " " " " " "
## 17 ( 1 ) " " "*" " " " " " " " "

33
## 18 ( 1 ) " " "*" " " " " " " " "
## 19 ( 1 ) " " "*" " " " " " " " "
## 20 ( 1 ) " " "*" "*" " " "*" " "
## 21 ( 1 ) " " "*" "*" " " "*" " "
## 22 ( 1 ) " " "*" "*" " " "*" " "
## 23 ( 1 ) " " "*" "*" " " "*" "*"
## 24 ( 1 ) "*" "*" "*" " " "*" " "
## 25 ( 1 ) "*" "*" "*" " " "*" " "
## 26 ( 1 ) "*" "*" "*" " " "*" "*"
## 27 ( 1 ) "*" "*" "*" " " "*" "*"
## 28 ( 1 ) "*" "*" "*" " " "*" "*"
## 29 ( 1 ) "*" "*" "*" " " "*" "*"
## 30 ( 1 ) "*" "*" "*" " " "*" "*"
## 31 ( 1 ) "*" "*" "*" " " "*" "*"
## 32 ( 1 ) "*" "*" "*" " " "*" "*"
## 33 ( 1 ) "*" "*" "*" " " "*" "*"
## 34 ( 1 ) "*" "*" "*" " " "*" "*"
## 35 ( 1 ) "*" "*" "*" " " "*" "*"
## 36 ( 1 ) "*" "*" "*" " " "*" "*"
## 37 ( 1 ) "*" "*" "*" " " "*" "*"
## 38 ( 1 ) "*" "*" "*" "*" "*" "*"
## 39 ( 1 ) "*" "*" "*" "*" "*" "*"
## Fjobteacher reasonhome reasonother reasonreputation guardianmother
## 1 ( 1 ) " " " " " " " " " "
## 2 ( 1 ) " " " " " " " " " "
## 3 ( 1 ) " " " " " " " " " "
## 4 ( 1 ) " " " " " " " " " "
## 5 ( 1 ) " " " " " " " " " "
## 6 ( 1 ) " " " " " " " " " "
## 7 ( 1 ) " " " " " " " " " "
## 8 ( 1 ) "*" " " " " " " " "
## 9 ( 1 ) "*" " " " " " " " "
## 10 ( 1 ) "*" " " " " " " " "
## 11 ( 1 ) "*" " " " " " " " "
## 12 ( 1 ) "*" " " " " " " " "
## 13 ( 1 ) "*" " " " " " " " "
## 14 ( 1 ) "*" " " " " " " " "
## 15 ( 1 ) "*" " " " " " " " "
## 16 ( 1 ) "*" " " " " " " " "
## 17 ( 1 ) "*" " " " " " " " "
## 18 ( 1 ) "*" " " " " " " " "
## 19 ( 1 ) "*" " " " " " " " "
## 20 ( 1 ) "*" " " " " " " " "
## 21 ( 1 ) "*" " " " " " " " "
## 22 ( 1 ) "*" " " " " " " " "
## 23 ( 1 ) "*" " " " " " " " "
## 24 ( 1 ) "*" " " " " "*" " "
## 25 ( 1 ) "*" " " " " "*" " "
## 26 ( 1 ) "*" " " " " "*" " "
## 27 ( 1 ) "*" " " " " "*" " "
## 28 ( 1 ) "*" " " " " "*" " "
## 29 ( 1 ) "*" " " "*" "*" " "
## 30 ( 1 ) "*" " " " " "*" " "
## 31 ( 1 ) "*" " " "*" "*" " "

34
## 32 ( 1 ) "*" "*" "*" "*" " "
## 33 ( 1 ) "*" "*" "*" "*" " "
## 34 ( 1 ) "*" "*" "*" "*" " "
## 35 ( 1 ) "*" "*" "*" "*" " "
## 36 ( 1 ) "*" "*" "*" "*" " "
## 37 ( 1 ) "*" "*" "*" "*" " "
## 38 ( 1 ) "*" "*" "*" "*" " "
## 39 ( 1 ) "*" "*" "*" "*" "*"
## guardianother traveltime studytime failures schoolsupyes famsupyes
## 1 ( 1 ) " " " " " " "*" " " " "
## 2 ( 1 ) " " " " " " "*" " " " "
## 3 ( 1 ) " " " " " " "*" "*" " "
## 4 ( 1 ) " " " " " " "*" "*" " "
## 5 ( 1 ) " " " " " " "*" "*" " "
## 6 ( 1 ) " " " " " " "*" "*" " "
## 7 ( 1 ) " " " " "*" "*" "*" " "
## 8 ( 1 ) " " " " "*" "*" "*" " "
## 9 ( 1 ) " " " " "*" "*" "*" " "
## 10 ( 1 ) " " " " "*" "*" "*" "*"
## 11 ( 1 ) " " " " "*" "*" "*" "*"
## 12 ( 1 ) " " " " "*" "*" "*" "*"
## 13 ( 1 ) " " " " "*" "*" "*" "*"
## 14 ( 1 ) " " " " "*" "*" "*" "*"
## 15 ( 1 ) " " " " "*" "*" "*" "*"
## 16 ( 1 ) " " " " "*" "*" "*" "*"
## 17 ( 1 ) " " " " "*" "*" "*" "*"
## 18 ( 1 ) " " " " "*" "*" "*" "*"
## 19 ( 1 ) "*" "*" "*" "*" "*" "*"
## 20 ( 1 ) " " " " "*" "*" "*" "*"
## 21 ( 1 ) "*" "*" "*" "*" "*" "*"
## 22 ( 1 ) "*" "*" "*" "*" "*" "*"
## 23 ( 1 ) "*" "*" "*" "*" "*" "*"
## 24 ( 1 ) "*" "*" "*" "*" "*" "*"
## 25 ( 1 ) "*" "*" "*" "*" "*" "*"
## 26 ( 1 ) "*" "*" "*" "*" "*" "*"
## 27 ( 1 ) "*" "*" "*" "*" "*" "*"
## 28 ( 1 ) "*" "*" "*" "*" "*" "*"
## 29 ( 1 ) "*" "*" "*" "*" "*" "*"
## 30 ( 1 ) "*" "*" "*" "*" "*" "*"
## 31 ( 1 ) "*" "*" "*" "*" "*" "*"
## 32 ( 1 ) "*" "*" "*" "*" "*" "*"
## 33 ( 1 ) "*" "*" "*" "*" "*" "*"
## 34 ( 1 ) "*" "*" "*" "*" "*" "*"
## 35 ( 1 ) "*" "*" "*" "*" "*" "*"
## 36 ( 1 ) "*" "*" "*" "*" "*" "*"
## 37 ( 1 ) "*" "*" "*" "*" "*" "*"
## 38 ( 1 ) "*" "*" "*" "*" "*" "*"
## 39 ( 1 ) "*" "*" "*" "*" "*" "*"
## paidyes activitiesyes nurseryyes higheryes internetyes romanticyes
## 1 ( 1 ) " " " " " " " " " " " "
## 2 ( 1 ) " " " " " " " " " " " "
## 3 ( 1 ) " " " " " " " " " " " "
## 4 ( 1 ) " " " " " " " " " " " "
## 5 ( 1 ) " " " " " " " " " " " "

35
## 6 ( 1 ) " " " " " " " " " " " "
## 7 ( 1 ) " " " " " " " " " " " "
## 8 ( 1 ) " " " " " " " " " " " "
## 9 ( 1 ) " " " " " " " " " " " "
## 10 ( 1 ) " " " " " " " " " " " "
## 11 ( 1 ) " " " " " " "*" " " " "
## 12 ( 1 ) " " " " " " "*" " " " "
## 13 ( 1 ) " " " " " " "*" " " "*"
## 14 ( 1 ) " " " " " " "*" " " "*"
## 15 ( 1 ) " " " " " " "*" " " "*"
## 16 ( 1 ) " " " " " " "*" " " "*"
## 17 ( 1 ) " " " " " " "*" " " "*"
## 18 ( 1 ) " " " " " " "*" " " "*"
## 19 ( 1 ) " " " " " " "*" " " "*"
## 20 ( 1 ) " " " " " " "*" " " "*"
## 21 ( 1 ) " " " " " " "*" " " "*"
## 22 ( 1 ) " " " " " " "*" "*" "*"
## 23 ( 1 ) " " " " " " "*" "*" "*"
## 24 ( 1 ) " " " " " " "*" "*" "*"
## 25 ( 1 ) " " " " " " "*" "*" "*"
## 26 ( 1 ) " " " " " " "*" "*" "*"
## 27 ( 1 ) "*" " " " " "*" "*" "*"
## 28 ( 1 ) "*" " " " " "*" "*" "*"
## 29 ( 1 ) "*" " " " " "*" "*" "*"
## 30 ( 1 ) "*" " " " " "*" "*" "*"
## 31 ( 1 ) "*" " " " " "*" "*" "*"
## 32 ( 1 ) "*" " " " " "*" "*" "*"
## 33 ( 1 ) "*" "*" " " "*" "*" "*"
## 34 ( 1 ) "*" "*" " " "*" "*" "*"
## 35 ( 1 ) "*" "*" " " "*" "*" "*"
## 36 ( 1 ) "*" "*" "*" "*" "*" "*"
## 37 ( 1 ) "*" "*" "*" "*" "*" "*"
## 38 ( 1 ) "*" "*" "*" "*" "*" "*"
## 39 ( 1 ) "*" "*" "*" "*" "*" "*"
## famrel freetime goout Dalc Walc health absences
## 1 ( 1 ) " " " " " " " " " " " " " "
## 2 ( 1 ) " " " " " " " " " " " " " "
## 3 ( 1 ) " " " " " " " " " " " " " "
## 4 ( 1 ) " " " " " " " " " " " " " "
## 5 ( 1 ) " " " " "*" " " " " " " " "
## 6 ( 1 ) " " " " "*" " " " " " " " "
## 7 ( 1 ) " " " " "*" " " " " " " " "
## 8 ( 1 ) " " " " "*" " " " " " " " "
## 9 ( 1 ) " " " " "*" " " " " "*" " "
## 10 ( 1 ) " " " " "*" " " " " "*" " "
## 11 ( 1 ) " " " " "*" " " " " "*" " "
## 12 ( 1 ) " " " " "*" " " " " "*" " "
## 13 ( 1 ) " " " " "*" " " " " "*" " "
## 14 ( 1 ) " " " " "*" " " " " "*" "*"
## 15 ( 1 ) " " "*" "*" " " " " "*" "*"
## 16 ( 1 ) " " "*" "*" " " " " "*" "*"
## 17 ( 1 ) " " "*" "*" " " " " "*" "*"
## 18 ( 1 ) " " "*" "*" " " " " "*" "*"
## 19 ( 1 ) " " "*" "*" " " " " "*" "*"

36
## 20 ( 1 ) " " "*" "*" " " " " "*" "*"
## 21 ( 1 ) " " "*" "*" " " " " "*" "*"
## 22 ( 1 ) " " "*" "*" " " " " "*" "*"
## 23 ( 1 ) " " "*" "*" " " " " "*" "*"
## 24 ( 1 ) " " "*" "*" " " " " "*" "*"
## 25 ( 1 ) " " "*" "*" " " " " "*" "*"
## 26 ( 1 ) " " "*" "*" " " " " "*" "*"
## 27 ( 1 ) " " "*" "*" " " " " "*" "*"
## 28 ( 1 ) " " "*" "*" " " " " "*" "*"
## 29 ( 1 ) " " "*" "*" " " " " "*" "*"
## 30 ( 1 ) " " "*" "*" "*" "*" "*" "*"
## 31 ( 1 ) " " "*" "*" "*" "*" "*" "*"
## 32 ( 1 ) " " "*" "*" "*" "*" "*" "*"
## 33 ( 1 ) " " "*" "*" "*" "*" "*" "*"
## 34 ( 1 ) " " "*" "*" "*" "*" "*" "*"
## 35 ( 1 ) "*" "*" "*" "*" "*" "*" "*"
## 36 ( 1 ) "*" "*" "*" "*" "*" "*" "*"
## 37 ( 1 ) "*" "*" "*" "*" "*" "*" "*"
## 38 ( 1 ) "*" "*" "*" "*" "*" "*" "*"
## 39 ( 1 ) "*" "*" "*" "*" "*" "*" "*"
which(summary(fit4)$bic == min(summary(fit4)$bic))

## [1] 8
summary(fit4)$bic

## [1] -48.16640192 -51.21253606 -53.61076364 -55.61760449 -57.12003108


## [6] -57.39708126 -57.58316897 -57.80787287 -56.96264204 -55.55059091
## [11] -53.45201258 -50.00644274 -46.25912180 -42.62827574 -38.97830766
## [16] -34.85507245 -30.23829336 -25.28442317 -20.27541500 -15.13715516
## [21] -10.25657501 -5.23527873 0.03386567 5.25357648 10.57408703
## [26] 16.03787921 21.54861319 27.15480777 32.90958983 38.72467964
## [31] 44.45350609 50.27156995 56.10851826 62.02905456 67.95868529
## [36] 73.93097808 79.90531129 85.88361754 91.86219365
The goodness-of-fit is BIC:-57.8079. The significant variables are sex + Mjob + Fjob + studytime + failures
+ schoolsup + goout
(From some tries, I found the Mjob and Sex:Fjob are dependent, so I choose to delet Fjob)
fit5 <- regsubsets((G1+G2+G3)/3 ~ (sex + Mjob + studytime + failures + schoolsup + goout)^2, data = data
summary(fit5)

## Subset selection object


## Call: regsubsets.formula((G1 + G2 + G3)/3 ~ (sex + Mjob + studytime +
## failures + schoolsup + goout)^2, data = data, nvmax = 10,
## nbest = 1, really.big = T)
## 39 Variables (and intercept)
## Forced in Forced out
## sexM FALSE FALSE
## Mjobhealth FALSE FALSE
## Mjobother FALSE FALSE
## Mjobservices FALSE FALSE
## Mjobteacher FALSE FALSE
## studytime FALSE FALSE
## failures FALSE FALSE

37
## schoolsupyes FALSE FALSE
## goout FALSE FALSE
## sexM:Mjobhealth FALSE FALSE
## sexM:Mjobother FALSE FALSE
## sexM:Mjobservices FALSE FALSE
## sexM:Mjobteacher FALSE FALSE
## sexM:studytime FALSE FALSE
## sexM:failures FALSE FALSE
## sexM:schoolsupyes FALSE FALSE
## sexM:goout FALSE FALSE
## Mjobhealth:studytime FALSE FALSE
## Mjobother:studytime FALSE FALSE
## Mjobservices:studytime FALSE FALSE
## Mjobteacher:studytime FALSE FALSE
## Mjobhealth:failures FALSE FALSE
## Mjobother:failures FALSE FALSE
## Mjobservices:failures FALSE FALSE
## Mjobteacher:failures FALSE FALSE
## Mjobhealth:schoolsupyes FALSE FALSE
## Mjobother:schoolsupyes FALSE FALSE
## Mjobservices:schoolsupyes FALSE FALSE
## Mjobteacher:schoolsupyes FALSE FALSE
## Mjobhealth:goout FALSE FALSE
## Mjobother:goout FALSE FALSE
## Mjobservices:goout FALSE FALSE
## Mjobteacher:goout FALSE FALSE
## studytime:failures FALSE FALSE
## studytime:schoolsupyes FALSE FALSE
## studytime:goout FALSE FALSE
## failures:schoolsupyes FALSE FALSE
## failures:goout FALSE FALSE
## schoolsupyes:goout FALSE FALSE
## 1 subsets of each size up to 10
## Selection Algorithm: exhaustive
## sexM Mjobhealth Mjobother Mjobservices Mjobteacher studytime failures
## 1 ( 1 ) " " " " " " " " " " " " "*"
## 2 ( 1 ) " " " " " " " " " " " " "*"
## 3 ( 1 ) " " " " " " "*" " " " " "*"
## 4 ( 1 ) " " " " " " "*" " " " " "*"
## 5 ( 1 ) " " " " " " "*" " " " " "*"
## 6 ( 1 ) " " " " " " "*" " " " " "*"
## 7 ( 1 ) " " " " " " "*" " " " " "*"
## 8 ( 1 ) "*" " " " " "*" " " "*" "*"
## 9 ( 1 ) "*" " " " " "*" " " "*" "*"
## 10 ( 1 ) "*" " " " " "*" " " "*" "*"
## schoolsupyes goout sexM:Mjobhealth sexM:Mjobother sexM:Mjobservices
## 1 ( 1 ) " " " " " " " " " "
## 2 ( 1 ) " " " " " " " " " "
## 3 ( 1 ) " " " " " " " " " "
## 4 ( 1 ) " " " " " " " " " "
## 5 ( 1 ) " " " " " " " " " "
## 6 ( 1 ) " " "*" " " " " " "
## 7 ( 1 ) " " "*" " " " " " "
## 8 ( 1 ) " " " " " " " " " "

38
## 9 ( 1 ) " " " " " " " " " "
## 10 ( 1 ) " " " " " " " " " "
## sexM:Mjobteacher sexM:studytime sexM:failures sexM:schoolsupyes
## 1 ( 1 ) " " " " " " " "
## 2 ( 1 ) " " " " " " " "
## 3 ( 1 ) " " " " " " " "
## 4 ( 1 ) " " " " " " " "
## 5 ( 1 ) " " "*" " " " "
## 6 ( 1 ) " " "*" " " " "
## 7 ( 1 ) " " "*" " " " "
## 8 ( 1 ) " " " " " " " "
## 9 ( 1 ) " " " " "*" " "
## 10 ( 1 ) " " " " "*" " "
## sexM:goout Mjobhealth:studytime Mjobother:studytime
## 1 ( 1 ) " " " " " "
## 2 ( 1 ) " " " " " "
## 3 ( 1 ) " " "*" " "
## 4 ( 1 ) " " "*" " "
## 5 ( 1 ) " " "*" " "
## 6 ( 1 ) " " "*" " "
## 7 ( 1 ) " " "*" " "
## 8 ( 1 ) " " "*" " "
## 9 ( 1 ) " " "*" " "
## 10 ( 1 ) " " "*" " "
## Mjobservices:studytime Mjobteacher:studytime Mjobhealth:failures
## 1 ( 1 ) " " " " " "
## 2 ( 1 ) " " " " " "
## 3 ( 1 ) " " " " " "
## 4 ( 1 ) " " " " " "
## 5 ( 1 ) " " " " " "
## 6 ( 1 ) " " " " " "
## 7 ( 1 ) " " " " " "
## 8 ( 1 ) " " " " " "
## 9 ( 1 ) " " " " " "
## 10 ( 1 ) " " " " " "
## Mjobother:failures Mjobservices:failures Mjobteacher:failures
## 1 ( 1 ) " " " " " "
## 2 ( 1 ) " " " " " "
## 3 ( 1 ) " " " " " "
## 4 ( 1 ) " " " " " "
## 5 ( 1 ) " " " " " "
## 6 ( 1 ) " " " " " "
## 7 ( 1 ) " " " " " "
## 8 ( 1 ) " " " " " "
## 9 ( 1 ) " " " " " "
## 10 ( 1 ) " " " " " "
## Mjobhealth:schoolsupyes Mjobother:schoolsupyes
## 1 ( 1 ) " " " "
## 2 ( 1 ) " " " "
## 3 ( 1 ) " " " "
## 4 ( 1 ) " " " "
## 5 ( 1 ) " " " "
## 6 ( 1 ) " " " "
## 7 ( 1 ) " " " "

39
## 8 ( 1 ) " " " "
## 9 ( 1 ) " " " "
## 10 ( 1 ) " " " "
## Mjobservices:schoolsupyes Mjobteacher:schoolsupyes Mjobhealth:goout
## 1 ( 1 ) " " " " " "
## 2 ( 1 ) " " " " " "
## 3 ( 1 ) " " " " " "
## 4 ( 1 ) " " " " " "
## 5 ( 1 ) " " " " " "
## 6 ( 1 ) " " " " " "
## 7 ( 1 ) " " " " " "
## 8 ( 1 ) " " " " " "
## 9 ( 1 ) " " " " " "
## 10 ( 1 ) " " " " " "
## Mjobother:goout Mjobservices:goout Mjobteacher:goout
## 1 ( 1 ) " " " " " "
## 2 ( 1 ) " " " " " "
## 3 ( 1 ) " " " " " "
## 4 ( 1 ) " " " " " "
## 5 ( 1 ) " " " " " "
## 6 ( 1 ) " " " " " "
## 7 ( 1 ) " " " " " "
## 8 ( 1 ) " " " " " "
## 9 ( 1 ) " " " " " "
## 10 ( 1 ) " " " " " "
## studytime:failures studytime:schoolsupyes studytime:goout
## 1 ( 1 ) " " " " " "
## 2 ( 1 ) " " " " " "
## 3 ( 1 ) " " " " " "
## 4 ( 1 ) " " " " " "
## 5 ( 1 ) " " " " " "
## 6 ( 1 ) " " "*" " "
## 7 ( 1 ) " " "*" " "
## 8 ( 1 ) " " "*" "*"
## 9 ( 1 ) " " "*" "*"
## 10 ( 1 ) " " "*" "*"
## failures:schoolsupyes failures:goout schoolsupyes:goout
## 1 ( 1 ) " " " " " "
## 2 ( 1 ) " " " " "*"
## 3 ( 1 ) " " " " " "
## 4 ( 1 ) " " " " "*"
## 5 ( 1 ) " " " " "*"
## 6 ( 1 ) " " " " " "
## 7 ( 1 ) "*" " " " "
## 8 ( 1 ) "*" " " " "
## 9 ( 1 ) "*" " " " "
## 10 ( 1 ) "*" "*" " "
which(summary(fit5)$bic == min(summary(fit5)$bic))

## [1] 6
summary(fit5)$bic

## [1] -48.16640 -53.83510 -57.17693 -64.01975 -66.14572 -66.75248 -65.62999

40
## [8] -65.19415 -61.35255 -58.86768
The final model is G ~ Mjob + failures + goout + sex:studytime + Mjob:studytime + studytime:schoolsup
The goodness of fit is BIC: -66.75248.
fit6 <- glm((G1+G2+G3)/3 ~ Mjob + failures + goout + sex:studytime + Mjob:studytime + studytime:schoolsu
par(mfrow = c(2,2))
plot(fit6)

Std. deviance resid.


Residuals vs Fitted Normal Q−Q
10

199
Residuals

2
0

0
−10

136
333243

−3
333243

4 6 8 10 12 14 16 18 −3 −2 −1 0 1 2 3

Predicted values Theoretical Quantiles


Std. deviance resid.

Std. Pearson resid.

Scale−Location Residuals vs Leverage


333
243
199
0 2
1.0

Cook's 141
260 distance
−3
0.0

243

4 6 8 10 12 14 16 18 0.00 0.05 0.10 0.15 0.20

Predicted values Leverage The


first picture tells us the resudals are not so symmetrically around 0, and from second plot, we can see the
residuals follows normal distribution, from the third picture, we can see homogeneity of variance of residauls
is basically satisfied, and from the last picture, we can see there are some outliers.
Outliers:
Diagnostics <- data.frame(Id = 1:395, y = (data$G1 + data$G2 + data$G3)/3, cd = cooks.distance(fit6), le
dffit = dffits(fit6))
print(subset(Diagnostics, abs(r)>=2 | lev > 4/9| cd > 4/9 | abs(dffit)> 2*sqrt(1/9)))

## Id y cd lev r dffit
## 111 111 18.666667 0.016927665 0.04552964 2.240661 0.4893753
## 114 114 18.666667 0.016055927 0.04864209 2.106188 0.4762459
## 130 130 18.000000 0.020791073 0.05220363 2.311916 0.5425813
## 132 132 2.666667 0.021510443 0.05219733 -2.352296 -0.5520230
## 135 135 3.000000 0.011738608 0.02381411 -2.615318 -0.4084844
## 136 136 3.666667 0.012673705 0.02531789 -2.633852 -0.4244960
## 137 137 3.333333 0.011877596 0.03225784 -2.245338 -0.4099393
## 141 141 5.333333 0.041130174 0.18813931 -1.579412 -0.7603165
## 149 149 4.333333 0.021234371 0.04864209 -2.426712 -0.5487220
## 199 199 18.000000 0.013274016 0.02647808 2.634230 0.4344342
## 243 243 2.000000 0.029597689 0.05220363 -2.766687 -0.6493112
## 245 245 2.333333 0.010560889 0.02222826 -2.568906 -0.3873310
## 246 246 18.000000 0.007576058 0.01923777 2.338963 0.3275811

41
## 260 260 6.333333 0.024859470 0.06970205 -2.165665 -0.5927929
## 266 266 17.000000 0.005454861 0.01879098 2.004823 0.2774405
## 270 270 2.000000 0.007677971 0.01879017 -2.383719 -0.3298675
## 287 287 18.333333 0.016633615 0.04044166 2.364722 0.4854660
## 317 317 5.333333 0.003906316 0.01308824 -2.039100 -0.2348227
## 333 333 2.333333 0.008778274 0.01514783 -2.853058 -0.3538346
## 375 375 18.666667 0.010287232 0.02222826 2.534835 0.3821938
## 388 388 4.000000 0.009785504 0.02970168 -2.125264 -0.3718354
Question 3:
The final model of question 1 and 2 are not same because we use different methods and criterions to select
variables. The limitations of our models are 1. we did not consider the randomness of the regressors 2. we did
not eliminate the outlier effect 3. we could try to do some transformation on y like yˆ2 ~ x or yˆ(1/2) ~ x.

42

You might also like