Do cars with bigger engines get fewer miles per gallon?
- Dataset:
mtcars, which has 32 cars disp: engine displacement (cubic inches)mpg: miles per gallon
2026-10-19
Do cars with bigger engines get fewer miles per gallon?
mtcars, which has 32 carsdisp: engine displacement (cubic inches)mpg: miles per gallonWe use simple linear regression to model mpg using disp.
mpgdisp\[ \text{mpg} = \beta_0 + \beta_1 \cdot \text{disp} + \varepsilon, \quad \varepsilon \sim N(0, \sigma^2) \]
The fitted model using our data is:
\[ \text{mpg} = \hat{\beta}_0 + \hat{\beta}_1 \cdot \text{disp} \]
The hats mean these are estimates from the data.
mod <- lm(mpg ~ disp, data = mtcars) summary(mod)
## ## Call: ## lm(formula = mpg ~ disp, data = mtcars) ## ## Residuals: ## Min 1Q Median 3Q Max ## -4.8922 -2.2022 -0.9631 1.6272 7.2305 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 29.599855 1.229720 24.070 < 2e-16 *** ## disp -0.041215 0.004712 -8.747 9.38e-10 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 3.251 on 30 degrees of freedom ## Multiple R-squared: 0.7183, Adjusted R-squared: 0.709 ## F-statistic: 76.51 on 1 and 30 DF, p-value: 9.38e-10
The line slopes downward, so cars with larger engines tend to have lower mpg.
The 4-cylinder cars have small engines and high mpg. The 8-cylinder cars have large engines and low mpg.