Question: a ) Write the simple linear regression equation for miles per gallon as the response variable and weight as the predictor variable. How might the
a
Write the simple linear regression equation for miles per gallon as the response variable and weight as the predictor variable. How might the car rental company use this model? See Step in the Python script.
b
What is the slope coefficient? Is this coefficient significant at a level of significance alphaHint: Check the Pvalue, P is greater than the absolute valueNow you will calculate the correlation coefficient between the miles per gallon and weight variables. The corr method of a dataframe returns the correlation matrix with correlation coefficients between all variables in the dataframe. In this case, you will specify to only return the matrix for the variables "miles per gallon" and "weight".
Click the block of code below and hit the Run button above.
# create correlation matrix for mpg and wt
# the correlation coefficient between mpg and wt is contained in the cell for mpg row and wt column or wt row and
mpg column
mpgwtcorr carsdf mpgwtcorr
printmpgwtcorr
Step : Simple linear regression model to predict miles per gallon using weight
The block of code below produces a simple linear regression model using "miles per gallon" as the response variable and "weight" of the car as a predictor variable. The ols method in statsmodels.formula.api submodule returns all statistics for this simple linear regression model.
Click the block of code below and hit the Run button above.
from statsmodels. formula.api import ols
# create the simple linear regression model with mpg as the response variable and weight as the predictor variable
model ols mpg datacarsdffit
#print the model summary
print modelsummary
OLS Regression Results
tableDep Variable:,Rsquared:,Model:OLS,Adj. Rsquared:,Method:Least Squares,Fstatistic:,Date:Wed, Feb Prob Fstatistic: of t for weight in the Python output. See Step in the Python script.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
