The second dataset we considered here is provided in a R pac

The second dataset we considered here is provided in a R package called \'datasets\'. It were first taken from a 1974 Motor Trend magazine, which originally records various design and performance characteristics of 32 cars (1973-74 models). A detailed description can be found in this link: As in assignment 3, we treat the mpg (miles per gallon) as the response variable and all the others as regressors. (Please treat all the regressors as continuous, though variable such as am(Transmission) can be considered as an Indicator variable) Perform a forward model selection using AIC. Provides the resulting model only with estimated parameters (do not just include your K output) Perform a forward model selection using BIC. Provides the resulting model only with estimated parameters (do not just include your R output) Perform a backward model selection using AIC. Provide the resulting model only with estimated parameters (do not just includes your R output) Perform a backward model selection using BIC. Provide the resulting model only with estimated parameters (do not just include your R output) You can load the dataset by running the following R code: install.packages(\'datasets\') library(datasets) data(mtcars) mtcars

Solution

R-Code:

install.packages(\'dataset\')
library(datasets)
data(\"mtcars\")
library(MASS)

fit <- lm(mpg ~ cyl+disp+hp+drat+wt+qsec+factor(vs)+factor(am)+gear+carb, data = mtcars)
step <- step(fit, direction=\"forward\",trace=FALSE,criterion = \"AIC\")
summary(step)


fit <- lm(mpg ~ cyl+disp+hp+drat+wt+qsec+factor(vs)+factor(am)+gear+carb, data = mtcars)
step <- step(fit, direction=\"forward\", trace=FALSE,criterion = \"BIC\")
summary(step)

fit <- lm(mpg ~ cyl+disp+hp+drat+wt+qsec+factor(vs)+factor(am)+gear+carb, data = mtcars)
step <- step(fit, direction=\"backward\", trace=FALSE,criterion = \"AIC\")
summary(step)

fit <- lm(mpg ~ cyl+disp+hp+drat+wt+qsec+factor(vs)+factor(am)+gear+carb, data = mtcars)
step <- step(fit, direction=\"backward\", trace=FALSE,criterion = \"BIC\")
summary(step)

Parameter Analysis:

1>Resulting model with estimated paramenter when perform forward model selection using AIC.

Residuals:
Min 1Q Median 3Q Max
-3.4506 -1.6044 -0.1196 1.2193 4.6271

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 12.30337 18.71788 0.657 0.5181
cyl -0.11144 1.04502 -0.107 0.9161
disp 0.01334 0.01786 0.747 0.4635
hp -0.02148 0.02177 -0.987 0.3350
drat 0.78711 1.63537 0.481 0.6353
wt -3.71530 1.89441 -1.961 0.0633 .
qsec 0.82104 0.73084 1.123 0.2739
factor(vs)1 0.31776 2.10451 0.151 0.8814
factor(am)1 2.52023 2.05665 1.225 0.2340
gear 0.65541 1.49326 0.439 0.6652
carb -0.19942 0.82875 -0.241 0.8122
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.65 on 21 degrees of freedom
Multiple R-squared: 0.869,   Adjusted R-squared: 0.8066
F-statistic: 13.93 on 10 and 21 DF, p-value: 3.793e-07

2>Resulting model with estimated paramenter when perform forward model selection using BIC.

Residuals:
Min 1Q Median 3Q Max
-3.4506 -1.6044 -0.1196 1.2193 4.6271

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 12.30337 18.71788 0.657 0.5181
cyl -0.11144 1.04502 -0.107 0.9161
disp 0.01334 0.01786 0.747 0.4635
hp -0.02148 0.02177 -0.987 0.3350
drat 0.78711 1.63537 0.481 0.6353
wt -3.71530 1.89441 -1.961 0.0633 .
qsec 0.82104 0.73084 1.123 0.2739
factor(vs)1 0.31776 2.10451 0.151 0.8814
factor(am)1 2.52023 2.05665 1.225 0.2340
gear 0.65541 1.49326 0.439 0.6652
carb -0.19942 0.82875 -0.241 0.8122
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.65 on 21 degrees of freedom
Multiple R-squared: 0.869,   Adjusted R-squared: 0.8066
F-statistic: 13.93 on 10 and 21 DF, p-value: 3.793e-07

3>Resulting model with estimated paramenter when perform backward model selection using AIC.

Call:

Residuals:
Min 1Q Median 3Q Max
-3.4811 -1.5555 -0.7257 1.4110 4.6610

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.6178 6.9596 1.382 0.177915
wt -3.9165 0.7112 -5.507 6.95e-06 ***
qsec 1.2259 0.2887 4.247 0.000216 ***
factor(am)1 2.9358 1.4109 2.081 0.046716 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.459 on 28 degrees of freedom
Multiple R-squared: 0.8497,   Adjusted R-squared: 0.8336
F-statistic: 52.75 on 3 and 28 DF, p-value: 1.21e-11

4>Resulting model with estimated paramenter when perform backward model selection using BIC.

Residuals:
Min 1Q Median 3Q Max
-3.4811 -1.5555 -0.7257 1.4110 4.6610

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.6178 6.9596 1.382 0.177915
wt -3.9165 0.7112 -5.507 6.95e-06 ***
qsec 1.2259 0.2887 4.247 0.000216 ***
factor(am)1 2.9358 1.4109 2.081 0.046716 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.459 on 28 degrees of freedom
Multiple R-squared: 0.8497,   Adjusted R-squared: 0.8336
F-statistic: 52.75 on 3 and 28 DF, p-value: 1.21e-11

 The second dataset we considered here is provided in a R package called \'datasets\'. It were first taken from a 1974 Motor Trend magazine, which originally re
 The second dataset we considered here is provided in a R package called \'datasets\'. It were first taken from a 1974 Motor Trend magazine, which originally re
 The second dataset we considered here is provided in a R package called \'datasets\'. It were first taken from a 1974 Motor Trend magazine, which originally re

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site