2026-04-13

Relationship Between Horsepower and Fuel Efficiency (1/8)

IoSlides Presentation Created by Isaac Layton

Using the included mtcars dataset.

Overview (2/8)

  • This presentation will explore the relationship/correlation between horsepower and fuel efficiency.
  • Horsepower will be labeled as “HP”
  • Fuel Efficiency will be measured/labeled as “MPG”
  • All data is gathered from the base mtcars dataset.

Plotly Plot (3/8)

plot_ly(
data = mtcars,
x = ~hp,
y = ~mpg,
type = "scatter",
mode = "markers",
color = ~factor(cyl), #dif colors for dif num of cylinders
size = ~wt,
sizes = c(10, 50),
marker = list(opacity = 0.8)
)

ggplot 1 (4/8)

ggplot 2 (5/8)

Linear Regression (LaTeX) (6/8)

\[ y = \beta_0 + \beta_1 x + \epsilon \]

  • \(y\) = fuel efficiency (mpg)
  • \(x\) = horsepower (hp)
  • \(\beta_0\) = intercept
  • \(\beta_1\) = slope

Interpretation Using LaTeX (7/8)

\[ \beta_1 = \frac{\Delta y}{\Delta x} \]

– This is the avg change in mpg for each horsepower added.

R code for ggplot1 (8/8)

ggplot(
  data= mtcars,
  aes(
    x = hp,
    y = mpg, 
    color = factor(cyl),
    size = wt
  )
) + geom_point(alpha = 0.8)