Question

The Motor Trend Car Road Tests dataset mtcars, in faraway R package, was extracted from the...

The Motor Trend Car Road Tests dataset mtcars, in faraway R package, was extracted from the 1974 Motor Trend US magazine, and comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models). The data frame has 32 observation on 11 (numeric) variables: mpg: Miles/(US) gallon; cyl: Number of cylinders; disp: Displacement (cu.in.); hp: Gross horsepower; drat: Rear axle ratio; wt: Weight (1000 lbs); qsec: 1/4 mile time; vs: Engine (0 = V-shaped, 1 = straight); am: Transmission (0 = automatic, 1 = manual); gear: Number of forward gears, and carb: Number of carburetors. Use mpg as the response variable. Fit a regression model with the mpg: Miles/(US) gallon as the response and the other variables as predictors. (a) What percentage of variation in the response is explained by these predictors? (3) STA3701/101/3/2019 (b) Which observation has the largest (positive) residual? Give the case number. (2) (c) Compute the mean and median of the residuals. (2) (d) Compute the correlation of the residuals with the fitted values. Interpret the result. (3) (e) Compute the correlation of the residuals with the cyl: Number of cylinders. What does the result imply? (3) (f) For all other predictors held constant what would be the difference in predicted Miles/(US) gallon for an automobile with automatic transmission compared to a manual transmission?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Fit the regression model in R by the below command.

model = lm(mpg ~ . , data = mtcars)

Store the summary of the model.

s = summary(model)

(a) What percentage of variation in the response is explained by these predictors?

Run the command s$r.squared

> s$r.squared
[1] 0.8690158

86.90% of variation in the response is explained by these predictors

b) Which observation has the largest (positive) residual? Give the case number.

Run the command which(s$residuals == max(s$residuals)) to get the observation with the largest (positive) residual.

> which(s$residuals == max(s$residuals))
Fiat 128
18

Fiat 128 (18th observation) has the highest positive residuals.

(c) Compute the mean and median of the residuals.

Mean and median of the residuals are 7.459311e-17 and -0.1196051

> mean(s$residuals)
[1] 7.459311e-17
> median(s$residuals)
[1] -0.1196051

(d) Compute the correlation of the residuals with the fitted values. Interpret the result.

Run the command cor(s$residuals, model$fitted.values) to get the correlation.

> cor(s$residuals, model$fitted.values)
[1] -1.557446e-16

Since the correlation of residuals and fitted values is almost 0, residuals and fitted values are independent of each other. This implies that the error term is independent of the fitted values.

(e) Compute the correlation of the residuals with the cyl: Number of cylinders. What does the result imply?

> cor(model$residuals, mtcars$cyl)
[1] -1.857654e-16

Since the correlation of residuals and cyl is almost 0, residuals and cyl are independent of each other.

(f) For all other predictors held constant what would be the difference in predicted Miles/(US) gallon for an automobile with automatic transmission compared to a manual transmission?

In the below output of the estimated linear regression, the estimated coefficient of am is 2.52023.

> model

Call:
lm(formula = mpg ~ ., data = mtcars)

Coefficients:
(Intercept) cyl disp hp drat wt qsec vs
12.30337 -0.11144 0.01334 -0.02148 0.78711 -3.71530 0.82104 0.31776
am gear carb
2.52023 0.65541 -0.19942

Thus, the difference in predicted Miles/(US) gallon for an automobile with automatic transmission compared to a manual transmission is 2.52023.

Add a comment
Know the answer?
Add Answer to:
The Motor Trend Car Road Tests dataset mtcars, in faraway R package, was extracted from the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The data set "mtcars" in R has 11 variables with 32 observations. A data frame with...

    The data set "mtcars" in R has 11 variables with 32 observations. A data frame with 32 observations on 11 variables. [, 1] mpg Miles/(US) gallon [, 2] cyl Number of cylinders [, 3] disp Displacement (cu.in.) [, 4] hp Gross horsepower [, 5] drat Rear axle ratio [, 6] wt Weight (1000 lbs) [, 7] qsec 1/4 mile time [, 8] vs V/S [, 9) am Transmission (0 = automatic, 1 = manual) [,10] gear Number of forward gears...

  • 6. The following data was extracted from the 1974 Motor Trend US magazine, and com- prises...

    6. The following data was extracted from the 1974 Motor Trend US magazine, and com- prises fuel consumption , mpg, (response) and 6 aspects of automobile design and per- formance (explanatory variables) for 32 automobiles (1973-74 models). mpg Miles/(US) gallon cyl Number of cylinders disp Displacement (cu.in.) hp Gross horsepower Transmission (0 = automatic, 1 = - manual) am 4 5 6 7 8 50 150 250 LULU O mpg P8 tagad 2008 10 25 QUE 000 cyl DOO DO...

  • Please show full details steps for better understanding. Thank you. 6. The following data was extracted...

    Please show full details steps for better understanding. Thank you. 6. The following data was extracted from the 1974 Motor Trend US magazine, and com- prises fuel consumption , mpg (response) and 6 aspects of automobile design and per- formance (explanatory variables) for 32 automobiles (1973-74 models). mpg Miles/(US) gallon cyl Number of cylinders disp Displacement (cu.in.) hp Gross horsepower am Transmission (0 = automatic, 1 = manual) 50 150 250 mpg 10 25 200 cyl 00 00000 ood 00...

  • 1. For each of the following regression models, write down the X matrix and 3 vector....

    1. For each of the following regression models, write down the X matrix and 3 vector. Assume in both cases that there are four observations (a) Y BoB1X1 + B2X1X2 (b) log Y Bo B1XiB2X2+ 2. For each of the following regression models, write down the X matrix and vector. Assume in both cases that there are five observations. (a) YB1XB2X2+BXE (b) VYBoB, X,a +2 log10 X2+E regression model never reduces R2, why 3. If adding predictor variables to a...

  • The data file Motor Trend is a random sample of 32 automobiles.   The miles per gallon ...

    The data file Motor Trend is a random sample of 32 automobiles.   The miles per gallon (mpg), weight (wt), horsepower (hp) and type of transmission (manual or automatic) is recorded for each sampled automobile. The file is available on Blackboard. Transmission is a categorical variable. Code the variable transmission so that it can be used in a regression model. Your coding should assign a 1 to manual transmission and a 0 to automatic. Develop a regression model with mpg as...

  • 1.1 Fuel Economy. (mpg) of model year 2016 motor vehicles Here is a small part of a data set that...

    1.1 Fuel Economy. (mpg) of model year 2016 motor vehicles Here is a small part of a data set that describes the fuel economy in miles per gallon Make and Vehicle Class Transmission Number of City Highway Annual Fuel Model Type Cylinders mpg mpg Cost Subaru Im Compact preza Nissan Juke Small station Manual Manual 4 25 34 $900 4 28 34 1,100 wagon Midsize Hyundai Elantra GT Automatic 24 $950 19 Chevrolet Im Large pala Automatic 29 1,150 The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT