Mtcars prediction model

Mahmoud Elsheikh
March 2nd,2019

Predection of Miles per (US) gallon:

  • The Link to the shiny app
  • The App predicts the Miles per (US) gallon after setting certain variables.
  • These variables are:
    • Number of cylinders
    • Displacement (cu.in.)
    • Gross horsepower
    • Rear axle ratio
    • Weight (1000 lbs)
    • ¼ mile time
    • Engine (0 = V-shaped, 1 = straight)
    • Transmission (0 = automatic, 1 = manual)
    • Number of forward gears
    • Number of carburetors

Insight about the app:

  • Based on the mtcars data from the library datasets.
  • A linear regression model is built on all variables in the data.
  • The application accepts entries for all variables then after clicking submit a prediction of the Mile per (US) gallon.
  • The result is shown graphically under the tab Plot.
  • Also shown numerically.

Prediction Model:

Prediction model is built as follows:

fit <- lm(mpg ~ ., data = mtcars)
summary(fit)$coeff[,1]
(Intercept)         cyl        disp          hp        drat          wt 
12.30337416 -0.11144048  0.01333524 -0.02148212  0.78711097 -3.71530393 
       qsec          vs          am        gear        carb 
 0.82104075  0.31776281  2.52022689  0.65541302 -0.19941925 

For More details:

For more details on the app code check the code in github:

ui.R code

server.R code

And the code for this presentation is:

This presentation code