What is Multiple Linear Regression?

Multiple linear regression models the relationship between one response variable and two or more explanatory variables.

For this example, the goal is to predict a car’s fuel economy using:

  • MPG: miles per gallon
  • Weight: vehicle weight in thousands of pounds
  • Horsepower: engine horsepower

The mtcars dataset contains measurements for 32 automobiles.

The Regression Model

A multiple linear regression model can be written as

\[ Y = \beta_0 + \beta_1X_1 + \beta_2X_2 + \epsilon \]

For this analysis:

\[ MPG = \beta_0 + \beta_1(Weight) + \beta_2(Horsepower) + \epsilon \]

where \(\epsilon\) represents variation that is not explained by the model.

Exploring Weight and Fuel Economy

Heavier vehicles generally have lower fuel economy.

Exploring Horsepower and Fuel Economy

Cars with greater horsepower also tend to have lower MPG.

Fitting the Model

The model can be created in R using the lm() function.

model <- lm(mpg ~ wt + hp, data = mtcars)

coef(model)
## (Intercept)          wt          hp 
## 37.22727012 -3.87783074 -0.03177295

The estimated coefficients show how MPG changes with weight and horsepower while holding the other predictor constant.

The Estimated Equation

Using the fitted model, the estimated regression equation is approximately

\[ \widehat{MPG} = 37.23 + (-3.88)(Weight) + (-0.03)(Horsepower) \]

The fitted coefficients are approximately:

  • Intercept: 37.23
  • Weight coefficient: -3.88
  • Horsepower coefficient: -0.032

Because both predictor coefficients are negative, increases in weight or horsepower are associated with decreases in predicted MPG.

Visualizing Three Variables

The interactive graph shows the relationship between vehicle weight and MPG, while marker color represents horsepower.

How Well Does the Model Fit?

##   R_squared Adjusted_R_squared
## 1 0.8267855          0.8148396

The coefficient of determination is

\[ R^2 = 0.827 \]

This means that approximately 82.7% of the variation in MPG is explained by vehicle weight and horsepower together.

Predicted vs. Actual MPG

Points close to the dashed line represent vehicles for which the model’s prediction is close to the actual MPG.

Conclusions

Multiple linear regression lets us examine several predictors at the same time.

In the mtcars data:

  • Weight and horsepower are both negatively associated with MPG.
  • Together, they explain about 82.7% of the variation in fuel economy.
  • The fitted model can be used to predict MPG from weight and horsepower.
  • Regression describes association, but does not by itself establish causation.

Overall, heavier and more powerful vehicles tend to have lower fuel economy.