Fuel Economy Predictor

Anand Venukrishnan
October 2026

A Shiny app that predicts a car's MPG from weight, horsepower and transmission

App: https://avk9056.shinyapps.io/mpg-predictor/

The Problem

  • Fuel cost is one of the biggest running costs of owning a car
  • Buyers often know a car's weight, horsepower and transmission, but not its real-world MPG
  • We want a quick, simple estimate that needs no statistics knowledge

The Fuel Economy Predictor turns three easy inputs into an MPG estimate with an uncertainty range.

The Model (evaluated live)

Linear regression on R's built-in mtcars data:

fit <- lm(mpg ~ wt + hp + am, data = mtcars)
round(coef(fit), 3)
(Intercept)          wt          hp          am 
     34.003      -2.879      -0.037       2.084 
round(summary(fit)$r.squared, 3)
[1] 0.84

The three inputs explain about 84% of the variation in MPG.

Example Prediction

plot of chunk unnamed-chunk-2

A 3,200 lb automatic car with 140 hp:

   fit  lwr  upr
1 19.5 14.1 24.9

The app shows this instantly and redraws as you move the sliders.

Why Use It?

  • Simple: two sliders, one radio button, one checkbox
  • Instant: predictions update reactively on every change
  • Honest: shows a 95% prediction interval, not just a single number
  • Documented: a built-in How to use tab explains every control

Try it: https://avk9056.shinyapps.io/mpg-predictor/

Code: https://github.com/YOUR-USERNAME/mpg-predictor