2026-10-27

The Problem and Dataset

  • Fuel efficiency helps people compare cars.
  • MPG means miles per gallon; higher MPG generally means better fuel efficiency.
  • We use R’s built-in mtcars dataset, containing information about 32 cars.
  • Our goal is to predict fuel efficiency from car specifications.

Model Development

  • We use multiple linear regression with R’s lm() function.
  • Inputs include car weight, horsepower, and transmission type.
  • The model estimates MPG based on these variables.
model <- lm(mpg ~ wt + hp + factor(am), data = mtcars)
summary(model)$r.squared
## [1] 0.8398903

The code fits the model and displays its R-squared value.

Interactive Shiny Application

  • Users select automatic or manual transmission.
  • Sliders adjust car weight and horsepower.
  • Clicking Predict MPG displays the estimated fuel efficiency.
  • A bar chart compares predicted MPG with the dataset average.

Results and Conclusion

  • Predictions change with the selected car specifications.
  • The application combines statistical modelling with an interactive interface.
  • It demonstrates a practical use of regression in R.

Try the application: https://tanush1801.shinyapps.io/MPG_Shiny_Project/