Simple prediction model predictiong miles per gallon from different variables

L.J.J. Timmermans
june 3rd, 2017

Using shiny application to look at different variables.

Link : https://leotimmermans.shinyapps.io/MTcarsPredictionModel/

Data

The data for the shiny spplication is taken from the mtcars dataset.
Choosen variables to make a prediction for miles per gallon:

  • Number of cylinders
  • Displacement (cu.in.)
  • Gross horsepower
  • Weight (1000 lbs)
  • Transmission
  • Gears

Summary of data

df <- mtcars
cnames <- c("mpg","cyl","disp","hp","wt", "am", "gear")
df <- df[,cnames]
str(df)
'data.frame':   32 obs. of  7 variables:
 $ mpg : num  21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
 $ cyl : num  6 6 4 6 8 6 8 4 4 6 ...
 $ disp: num  160 160 108 258 360 ...
 $ hp  : num  110 110 93 110 175 105 245 62 95 123 ...
 $ wt  : num  2.62 2.88 2.32 3.21 3.44 ...
 $ am  : num  1 1 1 0 0 0 0 0 0 0 ...
 $ gear: num  4 4 4 3 3 3 3 4 4 4 ...

Example miles per gallon predicted from horsepower

plot of chunk unnamed-chunk-2

Explanation

Plot contains:

  • observationpoints
  • regressionline
  • confidence interval
  • miles per gallon on y-axis
  • horsepower on x-axis