2026-03-07

Introduction

In this presentation I will hope to use simple linear regression to look at the relationship between a car’s weight and mileage. I will be using the mtcars dataset. The response variable is mpg (miles per gallon), and the predictor variables is wt (weight).

Example Data

This is what the data looks like:

##                    mpg    wt
## Mazda RX4         21.0 2.620
## Mazda RX4 Wag     21.0 2.875
## Datsun 710        22.8 2.320
## Hornet 4 Drive    21.4 3.215
## Hornet Sportabout 18.7 3.440
## Valiant           18.1 3.460

Scatterplot of mpg vs wt

Interactive Plotly Plot

Simple Linear Regression

Residual Plot

Regression Equation

The simple regression model is: \[ Y_i = \beta_0 + \beta_1 x_i + \varepsilon_i \]

Testing our Simple Regression

We will be making a prediction to see how accurate our regression is. Suppose a car weighs 3 thousand pounds. Then the predicted mpg is: \[ Y_i = b_0 + b_1(3.0) \]

## (Intercept)          wt 
##   37.285126   -5.344472

So the fuel efficient is about:

## (Intercept) 
##       21.25

Conclusion

In this dataset heavier cars are the ones that are most likely to have lower mileage. The scatterplot and regression line show a negative relationship. The residual plot shows the linear model is reasonable, however there is some curvature so not perfectly linear.