This problem will consider consider the mtcars dataset. We considered modeling m
ID: 3319527 • Letter: T
Question
This problem will consider consider the mtcars dataset. We considered modeling miles per gallon as depending linearly on the weight of the car (mpgwt), now, we will add more predictors and see if our predictions can be made more precise. In particular we will add the time it takes the car to go from a stop to complete a quarter mile (qsec) and an indicator of whether the car has an automatic or manual transmission (am, 0 for automatic, 1 for manual).
1. Now add qsec as an additional independent variable and fit the multiple linear regression model with these two predictors (mpg wt+qsec).
The following questions use the two variable model from Problem 1.
2. For two cars A and B that weigh the same, what would be the expected difference in mpg if car A can travel a quarter mile 2 seconds faster than car B?
3. Predict the fuel efficiency of a car in miles per gallon that weighs 3.5 thousand pounds and can complete a quarter mile in 17 seconds.
4. Find the largest (positive or negative) residual for this multiple regression model, and state which model of car it is.
Explanation / Answer
Q1.
Loading the mtcard dataset in R and fitting the multiple linear regression model:
> data("mtcars")
> model1 <- lm(mpg ~ wt + qsec, data = mtcars)
> model1
Call:
lm(formula = mpg ~ wt + qsec, data = mtcars)
Coefficients:
(Intercept) wt qsec
19.7462 -5.0480 0.9292
> summary(model1)
Call:
lm(formula = mpg ~ wt + qsec, data = mtcars)
Residuals:
Min 1Q Median 3Q Max
-4.3962 -2.1431 -0.2129 1.4915 5.7486
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 19.7462 5.2521 3.760 0.000765 ***
wt -5.0480 0.4840 -10.430 2.52e-11 ***
qsec 0.9292 0.2650 3.506 0.001500 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.596 on 29 degrees of freedom
Multiple R-squared: 0.8264, Adjusted R-squared: 0.8144
F-statistic: 69.03 on 2 and 29 DF, p-value: 9.395e-12
The model thus is:
mpg = 19.7462 - 5.0480 * wt + 0.9292 * qsec
Q2.
For two cars A and B that weight the same, the expected difference in mpg if the car A can travel a quarter mile 2 seconds faster than car B
= 0.9292 * 2
= 1.8584
Q3.
The predicted fuel efficiency in miles per gallon
that weighs 3.5 thousand pounds and can complete a quarter mile in 17 seconds
= 19.7462 - 5.0480 * 3.5 + 0.9292 * 17
= 17.8746
Q4.
> residuals(model1)
Mazda RX4 Mazda RX4 Wag
-0.81510855 -0.04822401
Datsun 710 Hornet 4 Drive
-2.52727880 -0.18056924
Hornet Sportabout Valiant
0.50388581 -2.96858808
Duster 360 Merc 240D
-2.14342291 2.17288034
Merc 230 Merc 280
-2.32371308 -0.18548760
Merc 280C Merc 450SE
-2.14300639 1.03101923
Merc 450SL Merc 450SLC
0.02886576 -2.19041433
Cadillac Fleetwood Lincoln Continental
0.44870314 1.47572368
Chrysler Imperial Fiat 128
5.74861230 5.66785310
Honda Civic Toyota Corolla
1.59752172 4.92578455
Toyota Corona Dodge Challenger
-4.39619858 -2.15289593
AMC Javelin Camaro Z28
-3.28152953 -1.38091265
Pontiac Firebird Fiat X1-9
3.02044258 -0.24021927
Porsche 914-2 Lotus Europa
1.53885259 2.58792829
Ford Pantera L Ferrari Dino
-1.41749041 -0.46588119
Maserati Bora Volvo 142E
-0.29121742 -1.59591510
> which.max(residuals(model1))
Chrysler Imperial
17
> which.min(residuals(model1))
Toyota Corona
21
Hence, the largest residual for this multiple regression model is 5.74861230
and the model of car is -
Chrysler Imperial
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.