What are the coefficients of correlation between miles per gallon and horsepower? Between miles per gallon and the weight of the car? What are the directions and strengths of these coefficients? Do the coefficients of correlation indicate a strong correlation, weak correlation, or no correlation between these variables? See Step 4 in the Python script. Write the multiple regression equation for miles per gallon as the response variable. Use weight and horsepower as predictor variables. See Step 5 in the Python script. How might the car rental company use this model?

MATLAB: An Introduction with Applications
6th Edition
ISBN:9781119256830
Author:Amos Gilat
Publisher:Amos Gilat
Chapter1: Starting With Matlab
Section: Chapter Questions
Problem 1P
icon
Related questions
Question
  1. What are the coefficients of correlation between miles per gallon and horsepower? Between miles per gallon and the weight of the car? What are the directions and strengths of these coefficients? Do the coefficients of correlation indicate a strong correlation, weak correlation, or no correlation between these variables? See Step 4 in the Python script.
  2. Write the multiple regression equation for miles per gallon as the response variable. Use weight and horsepower as predictor variables. See Step 5 in the Python script. How might the car rental company use this model?
Step 5: Multiple regression model to predict miles per gallon using weight and horsepower
This block of code produces a multiple regression model with "miles per gallon" as the response variable, and "weight" and "horsepower" as predictor
variables. The ols method in statsmodels.formula.api submodule returns all statistics for this multiple regression model.
Click the block of code below and hit the Run button above.
from statsmodels.formula.api import ols
# create the multiple regression model with mpg as the response variable; weight and horsepower as predictor variables.
model = ols('mpg ~ wt+hp', data=cars_df).fit()
print(model.summary())
Dep. Variable:
Model:
Method:
Date:
Time:
No. Observations:
Df Residuals:
Df Model:
Covariance Type:
Intercept
wt
hp
Omnibus:
Prob (Omnibus):
Skew:
Kurtosis:
coef
Least Squares
Sun, 11 Dec 2022
04:25:46
36.5178
-3.6425
-0.0330
mpg
OLS
std err
nonrobust
1.736
0.686
0.009
30
27
2
R-squared:
Adj. R-squared:
Prob (F-statistic):
F-statistic:
Log-Likelihood:
AIC:
BIC:
t
21.031
-5.312
-3.503
P>|t|
0.000
0.000
0.002
7.195
Durbin-Watson:
0.027 Jarque-Bera (JB):
1.011
Prob(JB):
3.641 Cond. No.
[0.025
32.955
-5.049
-0.052
0.815
0.801
59.52
1.27e-10
-69.947
145.9
150.1
0.975]
40.081
-2.236
-0.014
2.073
5.624
0.0601
624.
Transcribed Image Text:Step 5: Multiple regression model to predict miles per gallon using weight and horsepower This block of code produces a multiple regression model with "miles per gallon" as the response variable, and "weight" and "horsepower" as predictor variables. The ols method in statsmodels.formula.api submodule returns all statistics for this multiple regression model. Click the block of code below and hit the Run button above. from statsmodels.formula.api import ols # create the multiple regression model with mpg as the response variable; weight and horsepower as predictor variables. model = ols('mpg ~ wt+hp', data=cars_df).fit() print(model.summary()) Dep. Variable: Model: Method: Date: Time: No. Observations: Df Residuals: Df Model: Covariance Type: Intercept wt hp Omnibus: Prob (Omnibus): Skew: Kurtosis: coef Least Squares Sun, 11 Dec 2022 04:25:46 36.5178 -3.6425 -0.0330 mpg OLS std err nonrobust 1.736 0.686 0.009 30 27 2 R-squared: Adj. R-squared: Prob (F-statistic): F-statistic: Log-Likelihood: AIC: BIC: t 21.031 -5.312 -3.503 P>|t| 0.000 0.000 0.002 7.195 Durbin-Watson: 0.027 Jarque-Bera (JB): 1.011 Prob(JB): 3.641 Cond. No. [0.025 32.955 -5.049 -0.052 0.815 0.801 59.52 1.27e-10 -69.947 145.9 150.1 0.975] 40.081 -2.236 -0.014 2.073 5.624 0.0601 624.
Step 4: Correlation matrix for miles per gallon, weight and horsepower
Now you will calculate the correlation coefficient between the variables "miles per gallon" and "weight". You will also calculate the correlation coefficient
between the variables "miles per gallon" and "horsepower". The corr method of a dataframe returns the correlation matrix with the correlation coefficients
between all variables in the dataframe. You will specify to only return the matrix for the three variables.
Click the block of code below and hit the Run button above.
# create correlation matrix for mpg, wt, and hp.
# The correlation coefficient between mpg and wt is contained in the cell for mpg row and wt column (or wt row and mpg column).
# The correlation coefficient between mpg and hp is contained in the cell for mpg row and hp column (or hp row and mpg column).
mpg_wt_corr
cars_df[['mpg', 'wt', 'hp']].corr()
print (mpg_wt_corr)
wt
mpg
hp
mpg 1.000000 -0.855046 -0.788600
wt -0.855046 1.000000 0.670918
hp -0.788600 0.670918 1.000000
Transcribed Image Text:Step 4: Correlation matrix for miles per gallon, weight and horsepower Now you will calculate the correlation coefficient between the variables "miles per gallon" and "weight". You will also calculate the correlation coefficient between the variables "miles per gallon" and "horsepower". The corr method of a dataframe returns the correlation matrix with the correlation coefficients between all variables in the dataframe. You will specify to only return the matrix for the three variables. Click the block of code below and hit the Run button above. # create correlation matrix for mpg, wt, and hp. # The correlation coefficient between mpg and wt is contained in the cell for mpg row and wt column (or wt row and mpg column). # The correlation coefficient between mpg and hp is contained in the cell for mpg row and hp column (or hp row and mpg column). mpg_wt_corr cars_df[['mpg', 'wt', 'hp']].corr() print (mpg_wt_corr) wt mpg hp mpg 1.000000 -0.855046 -0.788600 wt -0.855046 1.000000 0.670918 hp -0.788600 0.670918 1.000000
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
MATLAB: An Introduction with Applications
MATLAB: An Introduction with Applications
Statistics
ISBN:
9781119256830
Author:
Amos Gilat
Publisher:
John Wiley & Sons Inc
Probability and Statistics for Engineering and th…
Probability and Statistics for Engineering and th…
Statistics
ISBN:
9781305251809
Author:
Jay L. Devore
Publisher:
Cengage Learning
Statistics for The Behavioral Sciences (MindTap C…
Statistics for The Behavioral Sciences (MindTap C…
Statistics
ISBN:
9781305504912
Author:
Frederick J Gravetter, Larry B. Wallnau
Publisher:
Cengage Learning
Elementary Statistics: Picturing the World (7th E…
Elementary Statistics: Picturing the World (7th E…
Statistics
ISBN:
9780134683416
Author:
Ron Larson, Betsy Farber
Publisher:
PEARSON
The Basic Practice of Statistics
The Basic Practice of Statistics
Statistics
ISBN:
9781319042578
Author:
David S. Moore, William I. Notz, Michael A. Fligner
Publisher:
W. H. Freeman
Introduction to the Practice of Statistics
Introduction to the Practice of Statistics
Statistics
ISBN:
9781319013387
Author:
David S. Moore, George P. McCabe, Bruce A. Craig
Publisher:
W. H. Freeman