Car Consumption Prediction

The prediction is based on a multivariate linear regression with the following model:

mpg ~ wt + cyl + am + hp

where:

  • wt = Weight expressed in lb/1000
  • cyl = Number of cylinders
  • am = Transmission (0 = automatic, 1 = manual)
  • hp = Gross horsepower

and the result is:

  • mpg = Miles/(US) gallon
  • lwr = The lower value of the confidence interval
  • upr = The upper value of the confidence interval

Regression Coefficients

fit <- lm(mpg ~ wt + cyl + am + hp, mpgData)
summary(fit)$coefficients
##                Estimate Std. Error   t value     Pr(>|t|)
## (Intercept) 33.70832390 2.60488618 12.940421 7.733392e-13
## wt          -2.49682942 0.88558779 -2.819404 9.081408e-03
## cyl6        -3.03134449 1.40728351 -2.154040 4.068272e-02
## cyl8        -2.16367532 2.28425172 -0.947214 3.522509e-01
## am1          1.80921138 1.39630450  1.295714 2.064597e-01
## hp          -0.03210943 0.01369257 -2.345025 2.693461e-02

The intercept represents the estimated MPG for am0 (Automatic transmission). The adjusted R2^ how much variation is explained by the model and is better for multivariate regressions than its unadjusted version.

summary(fit)$adj.r.squared
## [1] 0.8400875

Plotting the fit

plot of chunk unnamed-chunk-4

App Frontend

height

Thanks and links!

The Car Consumption Predictor app is hosted in shinyapps.io.

The source code can be found at Github.

Thanks for your attention!