Project: Modeling mpg

Ray Jones
24/05/2015

Why ?

Did you feel good about your Regression Models project ?

  • Remember, all you had to do was model mpg in mtcars

  • But… you felt you could have done better ?

  • You saw other results and thought “If only I'd tried …?”

  • You asked yourself “Where did it all go wrong ?”

  • Where it went wrong was - you didn't have this shiny app !

  • But now you do !

What ?

  • A simple lm() problem
  • Come up with your best model, say, mpg ~ I(1/hp):
data(mtcars)
par(mar=c(4,4,2,2))
plot(1/mtcars$hp, mtcars$mpg)
abline(lm(mpg ~ I(1/hp), data=mtcars))

plot of chunk unnamed-chunk-1

… and possible combinations with up to 9 other variables !

How ?

  • Run the Project shiny app
  • Control your model from the left side panel
  • Slider bars adjust the predictor exponents in your model
  • To exclude a predictor, set its exponent to zero
  • When ready, hit [Fit!]
  • Marvel at your results !
  • Results from your model are shown in the main panel
  • Model fitted: your model
  • Adjusted R-squared: your model's predicted variance vs sample (1.0 is perfection)
  • Diagnostic plots: the 4 diagnostic plots
  • Summary fit: the summary text describing your model results

Here's what you have to beat ...

… if you feel up to a challenge:

  • For a 1 predictor model try: mpg ~ I( disp-1.0 )

  • For a 2 predictor model try: mpg ~ I( wt-0.5 ) + I( hp-0.5 )

  • Then see if you can beat them …

  • …. good luck !