Engine Displacement

George Batten
July 25, 2014

How does the displacement of an engine correlate to other characteristics of a car and its engine? The shiny app I created lets you explore this question. This app allows you to compare engine displacement with the following characteristics:

  • Miles per gallon
  • Horsepower
  • Acceleration
  • Weight
  • Number of cylinders

Dataset

The dataset comes from the R package ISLR, which contains a number of datasets used in the book An Introduction to Statistical Learning with Applications in R, by Gareth James, Daniela Witten, Trevor Hastie, and Rob Tibshirani. This app uses the Auto dataset which contains 9 variables of 392 cars:mpg, cylinders, displacement, horsepower, weight, acceleration, year, origin, and name.

Output

By picking a variable to compare displacement to, the app will produce a scatter plot if the variable is continuous, and a boxplot if it is discrete.

plot of chunk unnamed-chunk-1

Adding a Model

For continuous variables, you can add a linear regression line or a cubic spline (or both!) to the plot. Additionally, you can play around with the smoothing parameter for the cubic spline to visually see when the model overfits the data.

plot of chunk unnamed-chunk-2