Introduction

Simple linear regression is a statistical method used to understand the relationship between two numerical variables.

In this presentation, we will explore how vehicle weight affects fuel efficiency.

We will use the built-in mtcars dataset in R.

The Linear Regression Model

Simple linear regression describes the relationship between a dependent variable and an independent variable.

The statistical model is:

\[ Y_i = \beta_0 + \beta_1 X_i + \varepsilon_i \]

Where:

  • \(Y_i\): Fuel efficiency (MPG)
  • \(X_i\): Vehicle weight (1,000 lbs)
  • \(\beta_0\): Intercept
  • \(\beta_1\): Regression coefficient (slope)
  • \(\varepsilon_i\): Random error

Exploring the mtcars Dataset

The built-in mtcars dataset contains 32 automobiles and 11 numerical variables.

Our analysis focuses on two variables:

  • mpg: Fuel efficiency (miles per gallon)
  • wt: Vehicle weight (1,000 pounds)

Research Question: Can vehicle weight predict fuel efficiency?

Variable Mean Minimum Maximum
MPG 20.09 10.40 33.90
Weight 3.22 1.51 5.42

Vehicle Weight vs. Fuel Efficiency

This scatter plot shows the relationship between vehicle weight and fuel efficiency.

Linear Regression with Best-Fit Line

The fitted regression line shows the estimated relationship between vehicle weight and MPG.

Interpretation: The downward-sloping red line indicates that heavier vehicles tend to have lower fuel efficiency.

Interactive 3D Visualization

Explore the relationship between vehicle weight, horsepower, and fuel efficiency.

Building a Regression Model in R

We use the lm() function to predict fuel efficiency based on vehicle weight.

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

summary(model)

predict(model, newdata = data.frame(wt = 3))

The model estimates fuel efficiency for a vehicle weighing 3,000 pounds.

Predicting Fuel Efficiency

The fitted regression equation is:

\[ \widehat{MPG} = 37.285 - 5.344 \times Weight \]

For a vehicle weighing 3,000 pounds:

\[ \widehat{MPG} = 37.285 - 5.344(3) \]

\[ \widehat{MPG} \approx 21.25 \]

Interpretation: A vehicle weighing 3,000 pounds is predicted to achieve approximately 21.25 miles per gallon according to this model.

Findings and Conclusion

Key Findings:

  • Vehicle weight and MPG have a negative relationship.
  • Heavier vehicles generally have lower fuel efficiency.
  • Each additional 1,000 pounds is associated with approximately 5.34 fewer MPG.
  • Predicted fuel efficiency for a 3,000-pound vehicle is approximately 21.25 MPG.

Limitations:

  • The dataset contains only 32 automobiles.
  • Other factors may also influence fuel efficiency.

Conclusion: Simple linear regression helps identify statistical relationships and make data-driven predictions.