Li Jiming
24/09/2015
Customers are very concscious with fuel efficiency, for various reasons:
It's important to be able to predict the fuel efficiency of new cars during the design stage. Many factors can effect the fuel efficiency, including:
The mtcars dataset can be used to build a model of the effects of car characteristics on fuel efficiency. An example of the data is below:
data(mtcars); library(xtable)
print(xtable(mtcars[1:8,]), type = "html")
Henderson and Velleman (1981), Building multiple regression models interactively. Biometrics, 37, 391-411.
Using a linear model, I determined the effect of gross horsepower, number of cylinders, and weight on fuel efficiency (mpg), and used this model to create a function to predict fuel efficiency based on these factors.
modelFit <- lm(mpg ~ hp + cyl + wt, data=mtcars)
modelFit$coefficients
mpg <- function(hp, cyl, wt) {
modelFit$coefficients[1] + modelFit$coefficients[2] * hp +
modelFit$coefficients[3] * cyl + modelFit$coefficients[4] * wt
}
https://ljm1810.shinyapps.io/ShinyProject
The user inputs predictor values in the left sidebar, fuel effiency predictions are output to the main panel, and plots below the prediction show how the mpg compares with data from the mtcars dataset.