MPG Model Fit Visualization App

Chris Grill
07/26/2014

Overview

An app to quickly see how different factors in the mtcars data set affect the regression model for fuel efficiency.

  • Select from a list of factors
  • Plots and summary are updated when factor selection changes

Detail

The server.R file adds parameters to the call to lm. For example, if am and gear are selected, the lm call is :

fit<-lm(mpg~am+gear,data=mtcars)
summary(fit)

Call:
lm(formula = mpg ~ am + gear, data = mtcars)

Residuals:
   Min     1Q Median     3Q    Max 
-9.446 -3.058 -0.279  3.274  9.542 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)  
(Intercept)  16.8647     6.5117    2.59    0.015 *
am            7.1416     2.9523    2.42    0.022 *
gear          0.0881     1.9967    0.04    0.965  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 4.99 on 29 degrees of freedom
Multiple R-squared:  0.36,  Adjusted R-squared:  0.316 
F-statistic: 8.15 on 2 and 29 DF,  p-value: 0.00155

The formula is updated reactivley so all output is dynamically up to date.

Screenshot

Screenshot

Possible Improvements and URL

  • Add second set of selections to enable analysis of interactions
  • Allow selection of other data sets

Available at http://chrisgrill.shinyapps.io/CRGDDP