# problem-11.22

problem-11.22 We fit the ANCOVA model first:

    > library(MASS)                 # for stepAIC
    > kid.weights$BMI = (kid.weights$weight/2.54)/ (kid.weights$height*2.54/100)^2
    > res.full = lm(BMI ~ age + gender, kid.weights)
    > res.age  = lm(BMI ~ age, kid.weights)
    > res.gender  = lm(BMI ~ gender, kid.weights)
    > anova(res.full, res.age)
    Analysis of Variance Table

    Model 1: BMI ~ age + gender
    Model 2: BMI ~ age
      Res.Df  RSS  Df Sum of Sq    F Pr(>F)
    1    247 9686
    2    248 9686  -1     -0.25 0.01   0.94
    > anova(res.full, res.gender)
    Analysis of Variance Table

    Model 1: BMI ~ age + gender
    Model 2: BMI ~ gender
      Res.Df  RSS  Df Sum of Sq    F Pr(>F)
    1    247 9686
    2    248 9722  -1       -37 0.93   0.33
    > stepAIC(res)

    ...
    Call:
    lm(formula = BMI ~ 1, data = kid.weights)

    Coefficients:
    (Intercept)
             17

We see that neither variable is significant by stepAIC().