#complete second order model
full.model <- lm(Strength ~ (Cement + Water + Coarse.Aggregate)^2 +
I(Cement^2) + I(Water^2) + I(Coarse.Aggregate^2),
data = concrete.df)
#complete second order model
full.model <- lm(Strength ~ (Cement + Water + Coarse.Aggregate)^2 +
I(Cement^2) + I(Water^2) + I(Coarse.Aggregate^2),
data = concrete.df)
# backwards stepwise model selection
step(full.model, direction = "backward")
# output of the final step
Step: AIC=519.54
Strength ~ Cement + Water + Coarse.Aggregate + I(Water^2) + Water:Coarse.Aggregate
Df Sum of Sq RSS AIC
<none> 16004 519.54
- I(Water^2) 1 691.74 16695 521.77
- Water:Coarse.Aggregate 1 2490.36 18494 532.00
- Cement 1 3105.32 19109 535.27
# backwards stepwise model selection
step(full.model, direction = "backward")
# output of the final step
Step: AIC=519.54
Strength ~ Cement + Water + Coarse.Aggregate + I(Water^2) + Water:Coarse.Aggregate
Df Sum of Sq RSS AIC
<none> 16004 519.54
- I(Water^2) 1 691.74 16695 521.77
- Water:Coarse.Aggregate 1 2490.36 18494 532.00
- Cement 1 3105.32 19109 535.27
I attempted to determine if this model was the best fit for the data by looking at the AnovaANOVA table
# final model
final.model <- lm(Strength ~ Cement + Water + Coarse.Aggregate +
Coarse.Aggregate:Water, data = concrete.df)
# final model
final.model <- lm(Strength ~ Cement + Water + Coarse.Aggregate +
Coarse.Aggregate:Water, data = concrete.df)
The assignment was marked and the feedback I was provided mentioned that the AnovaANOVA is unnecessary and I shouldn't combine using AIC and p-value variable selection within the same model building exercise.