• Unless otherwise stated, all data sets are from the faraway package in R. • Un
ID: 3062061 • Letter: #
Question
• Unless otherwise stated, all data sets are from the faraway package in R.
• Unless otherwise stated, use a 5% level ( = 0.05) in all tests.
2. Use the seatpos data set with hipcenter as the response and only the variables Age, Weight, Ht, and Leg as possible predictors. Implement the following variable selection methods to determine a model. In each case, (i) show appropriate R output, and (ii) list the independent variables in the final model. (a) Forward selection (use Fin 3) (b) Backward elimination (use Fout 3) (c) Selection with the R function leaps, according to minimum CpExplanation / Answer
>library(faraway)
>data=seatpos
>names(data)
>data=data[,c('hipcenter','Age','Weight','Leg','Ht')]
> # Forword selection
> null=lm(hipcenter~1, data=data)
> full=lm(hipcenter~., data=data)
> step(null, scope=list(lower=null, upper=full), direction="forward")
Start: AIC=311.71
hipcenter ~ 1
Df Sum of Sq RSS AIC
+ Ht 1 84023 47616 275.07
+ Leg 1 81568 50071 276.98
+ Weight 1 53975 77664 293.66
<none> 131639 311.71
+ Age 1 5541 126098 312.07
Step: AIC=275.07
hipcenter ~ Ht
Df Sum of Sq RSS AIC
+ Leg 1 2781.10 44835 274.78
<none> 47616 275.07
+ Age 1 2353.51 45262 275.14
+ Weight 1 195.86 47420 276.91
Step: AIC=274.78
hipcenter ~ Ht + Leg
Df Sum of Sq RSS AIC
+ Age 1 2896.6 41938 274.24
<none> 44835 274.78
+ Weight 1 445.1 44390 276.40
Step: AIC=274.24
hipcenter ~ Ht + Leg + Age
Df Sum of Sq RSS AIC
<none> 41938 274.24
+ Weight 1 46.827 41891 276.20
Call:
lm(formula = hipcenter ~ Ht + Leg + Age, data = data)
Coefficients:
(Intercept) Ht Leg Age
452.1976 -2.3254 -6.7390 0.5807
final model is using forward selection
hipcenter=452.1976 -2.3254 *Ht -6.7390*Leg +0.5807*Age
# Backward selection
> full=lm(hipcenter~., data=data)
> step(full, data=data, direction="backward")
Start: AIC=276.2
hipcenter ~ Age + Weight + Leg + Ht
Df Sum of Sq RSS AIC
- Weight 1 46.8 41938 274.24
<none> 41891 276.20
- Age 1 2498.3 44390 276.40
- Leg 1 3370.8 45262 277.14
- Ht 1 3642.9 45534 277.37
Step: AIC=274.24
hipcenter ~ Age + Leg + Ht
Df Sum of Sq RSS AIC
<none> 41938 274.24
- Age 1 2896.6 44835 274.78
- Leg 1 3324.2 45262 275.14
- Ht 1 4238.3 46176 275.90
Call:
lm(formula = hipcenter ~ Age + Leg + Ht, data = data)
Coefficients:
(Intercept) Age Leg Ht
452.1976 0.5807 -6.7390 -2.3254
final model is using Backward selection
hipcenter=452.1976 -2.3254 *Ht -6.7390*Leg +0.5807*Age
Both method give same model that's no need selection you use this model as final model .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.