Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Is at least one of the two variables (weight and horsepower) significant in the model? Run the overall F-test and provide your interpretation at 5%

  1. Is at least one of the two variables (weight and horsepower) significant in the model? Run the overall F-test and provide your interpretation at 5% level of significance. See Step 5 in the Python script. Include the following in your analysis:
    1. Define the null and alternative hypothesis in mathematical terms and in words.
    2. Report the level of significance.
    3. Include the test statistic and the P-value. (Hint: F-Statistic and Prob (F-Statistic) in the output).
    4. Provide your conclusion and interpretation of the test. Should the null hypothesis be rejected? Why or why not?
  2. What is the slope coefficient for the weight variable? Is this coefficient significant at 5% level of significance (alpha=0.05)? (Hint: Check the P-value,, for weight in Python output. Recall that this is the individual t-test for the beta parameter.) See Step 5 in the Python script.
  3. What is the slope coefficient for the horsepower variable? Is this coefficient significant at 5% level of significance (alpha=0.05)? (Hint: Check the P-value,, for horsepower in Python output. Recall that this is the individual t-test for the beta parameter.) See Step 5 in the Python script.
  4. What is the purpose of performing individual t-tests after carrying out the overall F-test? What are the differences in the interpretation of the two tests?
  5. What is the coefficient of determination of your multiple regression model from Module Six? Provide appropriate interpretation of this statistic.
image text in transcribed
Module Six Discussion: Multiple Regression This notebook contains the step-by-step directions for your Module Six discussion. It is very important to run through the steps in order. Some steps depend on the outputs of earlier steps. Once you have completed the steps in this notebook, be sure to answer the questions about this activity in the discussion for this module. Reminder. If you have not already reviewed the discussion prompt, please do so before beginning this activity. That will give you an idea of the questions you will need to answer with the outputs of this script. Initial post (due Thursday) Step 1: Generating cars dataset we will generate the sample data for you. You will not be generating the data set using numpy module this week. Instead, the data set will be imported from a CSV file. To make the data unique to you, a random sample of size 30, without replacement, will be drawn from the data in the CSV file The data set will be saved in a Python dataframe that will be used in later calculations. Click the block of code below and hit the Run button above. In [1]: import pandas as pd from IPython. display import display, HTML # read data from mtcars. csy data set. cars_df_orig - pd. read_csv("https://53-us-west-2. amaz -analytics. zybooks . com/mtcars.csv") # randomly pick 30 observations from the data set to make the data set unique to you. cars_df = cars_df_orig. sample(n=30, replace=False) display (HTML(cars_df . head() . to_html())) Cars data frame (showing only the first five observations) Unnamed: 0 mpg cyl disp hp drat wt qsec vs am gear carb 23 Camaro Z28 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4 6 Duster 360 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4 19 Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 26 Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2 8 Merc 230 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2 Step 2: Scatterplot of miles per gallon against weight The block of code below ill create a scatterplot of the variables "miles per gallon" (coded as mpg in the data set) and "weight" of the car (coded as wt). Click the block of code below and hit the Run button above. NOTE: If th t created, click the code secti In [3]: import matplotlib. pyplot as pl # create scatterplot of variables mpg against wt. pit. plot(cars_df["wt"], cars_of["mpg"], 'o', color='red" ) # set a title for the plot, x-axis, and y-axis. pit. title('MPG against Weight" ) pit.xlabel("weight (1080s lbs)") pit.ylabel('MPG" ) # show the plot. It. show() MPG against Weight 15 15 20 25 30 35 40 45 50 55 Step 3: Scatterplot of miles per gallon against horsepower The block of code below will create a scatterplot of the variables "miles per gallon" (coded as mpg in the data set) and "horsepower ver" of the car (coded as hp). Click the block of code below and hit the Run button above. NOTE: If the plot is not created, click the code secti ection and hit the Run button again. In [4]: import matplotlib. pyplot as pit # create scatterplot of variables mpg against hp. pit.plot(cars_df["hp"], cars_df["mpg"], 'o', color='blue") # set a title for the plot, x-axis, and y-axis. pit. title("MPG against Horsepower' ) pit.xlabel('Horsepou pit. ylabel('MPG' ) # show the plot. it. show() MPG against Horsepower 25 100 150 200 2 250 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. In [5]: # create correlation matrix for mpg, for mpg, wt, and ni pg and wt is contained in the cell for mpg row and wt column (or wt row and mpg co * The correlation coefficient between mog and hp is contained in the cell for mog row and he column ( or hp row and mos column)' mpg_wt_corr - cars_of[['mpg' , 'wt' , "hp']].corr() print (mpg_wt_corr) -0.872545 -0.784310 t -0.872545 1.080080 0.662196 hp -0.784310 0.662196 1.080808 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 retums all statistics for this multiple regression model. Click the block of code below and hit the Run button above. In [6]: from statsmodels. formula. api import ols # create the multiple regression model with mpg as the response variable; weight and horsepower as predictor variables. ('mpg ~ wtthp' , data-cars_of) .fit() print (model . summary ()) OLS Regression Results Dep. Variable: mpg R-squared: 8.837 Adj. R-squared: Least Squares F-statistic: 69.47 Dime Fri, 08 Apr 2022 Prob (F-statistic): Time: 15:59:35 Log-Likelihood: 2.26e-11 -69.359 Jo. Observations 30 Of Residuals ALL: 148-9 Of Model: Covariance Type: coef std err p>It 10-825 0.975] Intercept 37. 2580 -3.8324 23.441 40 . 519 0.631 e.eee -5.128 -2.537 hp -0.0321 0.089 -3.550 0.801 -0.051 -0.014 Omnibus : 5.639 Durbin-Watson: 2.502 Prob (Omnibus): Jarque-Bera (JB) : Skew : Prob ( JB) : 4.401 Kurtosis : 3: 277 Cond. No. Warnings : [1] Standard Errors assume that the covariance matrix of the errors is correctly specified. End of initial post Attach the HTML output to your initial post in the Module Six discussion. The HTML output can be downloaded by clicking File, then Download as, then HTML. Be sure to answer all questions about this activity in the Module Six discussion. Follow-up posts (due Sunday) Return to the Module Six discussion to answer the follow-up questions in your response posts to other students. There are no Python scripts to run for your follow-up posts

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Applied Regression Analysis And Other Multivariable Methods

Authors: David G. Kleinbaum, Lawrence L. Kupper, Azhar Nizam, Eli S. Rosenberg

5th Edition

1285051084, 978-1285963754, 128596375X, 978-1285051086

More Books

Students also viewed these Mathematics questions

Question

A service window closes just as they get to the front of the line.

Answered: 1 week ago