Chaithra
March 22, 2026
The relationship between a car's power and its fuel efficiency is a critical metric for consumers.
summary(mtcars[, c("mpg", "hp")])
mpg hp
Min. :10.40 Min. : 52.0
1st Qu.:15.43 1st Qu.: 96.5
Median :19.20 Median :123.0
Mean :20.09 Mean :146.7
3rd Qu.:22.80 3rd Qu.:180.0
Max. :33.90 Max. :335.0
A quick look at the regression line shows exactly how fuel economy drops as horsepower climbs.
plot(mtcars$hp, mtcars$mpg, pch=19, col="blue", xlab="Horsepower", ylab="MPG")
abline(lm(mpg ~ hp, data=mtcars), col="red", lwd=2)
Our app uses a Linear Regression model. For any horsepower input, we calculate the expected MPG using this formula:
model <- lm(mpg ~ hp, data = mtcars)
coef(model)
(Intercept) hp
30.09886054 -0.06822828
The Logic: For every 10-point increase in horsepower, you can expect a drop of approximately 0.7 MPG.