2025-10-19

Hypothesis

Conventional knowledge would tell us that a lighter car can go faster than a heavier one; this hypothesis will be tested by comparing the wt (weight in thousands of pounds) and qsec (seconds to go a quarter mile).

Hypothesis testing is a statistical method in which analyzing a sample allows one to make inferences about the population it was pulled from.

Our null hypothesis (H₀): The starting assumption is that lighter cars go faster than heavier ones.

Our alternative hypothesis (H₁): Lighter cars do not always go faster than heavier ones.

To Be Evaluated

We will evaluate the following:

  • Car weight graphed against speed (ggplot)
  • Qsec of every car plotted against the wt of every car (plotly)
  • Average speed of cars in upper vs lower half of weight in dataset (ggplot)

Car weight graphed against qsec

## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

Qsec of every car plotted against the wt of every car (plotly)

Plotly graph math

Slowest car: Merc 230 with \(22.9\) qsec
Fastest car: Ford Pantera L with \(14.5\) qsec

Code for plotly graph

mtcars$carname <-rownames(mtcars)
md <- lm(qsec ~ wt, data = mtcars)
mtcars$trend <- predict(md)
plot2 <- plot_ly(mtcars, x = ~wt, y = ~qsec,
type = 'scatter', 
mode = 'markers', text = ~carname,
name = "Data Points") %>% 
add_lines(x = ~wt,
y = ~trend, name = "Trend Line")
plot2 <- plot2 %>% style(traces = 2,
line = list(color='purple', width=3))
plot2

Average speed of cars in upper vs lower half of weight in dataset (ggplot)

Math used in previous slide

medianwt = \(3.325\)
lightermean = \(18.33938\)
heaviermean = \(17.35813\)

Conclusion

  • We expected the lower wt cars to have a lower qsec, meaning a faster acceleration. However, the data showed the opposite correlation.
  • On average, heavier cars ended up having lower qsec values than lighter cars.
  • The data is inconclusive, but we know for sure that our alternative hypothesis is true.