Exploring 'Mile Per Gallon' consumptions App

Pier Lorenzo Paracchini
24.01.2016

Exploratory Analysis Made Easy

A simple and intuitive application that can be used by anyone to explore how the fuel comsumptions is affected by 10 aspects/ features of automobile design and performance using the mtcars dataset.

Assumptions:

  • Response variable (\( Y \)): Mile Per Gallon consumption (mpg)
  • Predictor variable (\( X \)): any of the other features
  • Simple Regression Model between the response and selected predictor
    • \( Y = \beta_0 + \beta_1 X + \epsilon \)
    • where \( \epsilon \) is \( N(0, \sigma^2) \), and \( \epsilon_i \) are iid

UI Overview

SideBar Panel allows the user to select the predictor she/ he is interested in

Main Panel allows the user to view the information available for the selected predictor

- Plot, shows a scatterplot and, an optional boxPlot, of the available observations response ~ predictor

- Summary, shows some basic statistical information about the predictor and the fitted simple regression model

- Data, shows the raw data used by the application, limited to the response and selected predictor

UI Overview

Simple Linear Regression Model Details

An example of how the simple regression model is fitted using the mtcars dataset. Note the responsevariable is mpg while the predictor variable is cyl.

library(datasets)
fittedModel <- lm(mpg ~ cyl, data = mtcars)
summary(fittedModel)

Call:
lm(formula = mpg ~ cyl, data = mtcars)

Residuals:
    Min      1Q  Median      3Q     Max 
-4.9814 -2.1185  0.2217  1.0717  7.5186 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  37.8846     2.0738   18.27  < 2e-16 ***
cyl          -2.8758     0.3224   -8.92 6.11e-10 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 3.206 on 30 degrees of freedom
Multiple R-squared:  0.7262,    Adjusted R-squared:  0.7171 
F-statistic: 79.56 on 1 and 30 DF,  p-value: 6.113e-10

Plot Details

An example of a scatterplot using the mtcars dataset, having mpg as response variable and cyl as predictor variable. The black line represents the predictions made using the simple regression model fitted using the available observations.

plot of chunk unnamed-chunk-2