-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmpg_predict.Rpres
More file actions
68 lines (49 loc) · 2.12 KB
/
mpg_predict.Rpres
File metadata and controls
68 lines (49 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<style>
.small-code pre code {
font-size: 0.9em;
}
</style>
MPG Predictor
========================================================
author: Armando Guereca
date: Nov 19, 2015
Introduction
========================================================
In 1974 Motor Trend a US magazine, performed road tests for 32 cars in the 1973-74 model year. They recorded 11 statistics about each model of car, the results are available on the data-set **mtcars** as part of R.
This application will help you estimate the expected change on MPG consumption of each of the 32 cars in the scenario that you alter the factory gross Horsepower or if the total Weight of the vehicle is changed by additional load that you might plan to carry on it.
Our MPG Predictor might prove useful to estimate your gasoline cost on your next family trip, giving you a quantitative argument to reduce the total luggage weight.
Usage
========================================================
To use this tool is as simple as 1,2,3…
- *Vehicle selection*
Identify your vehicle (or the closest one) in the left list.
- *Experiment*
Using the sliders you can select a new value for the total Weight (lb/1000).
- *Results*
The resulting prediction is available on the first tab of the right panel.
Regression model used on our prediction
========================================================
class: small-code
```{r echo=FALSE, results='hide'}
# This are all libraries that we are going to use
library(knitr); library(ggplot2);
cars_data <- mtcars
# Defined factor columns
cars_data$cyl <- factor(cars_data$cyl)
cars_data$vs <- factor(cars_data$vs)
cars_data$am <- factor(cars_data$am)
levels(cars_data$am) <-c ("automatic", "manual")
cars_data$gear <- factor(cars_data$gear)
cars_data$carb <- factor(cars_data$carb)
full <- glm(mpg~., cars_data, family="gaussian") # Linear model across all dimentions
fit <- step(full, direction="both") # Identify the most influential confounders.
```
```{r}
summary(fit)
```
Quick look into our model's residuals
========================================================
```{r, echo=FALSE, fig.align="center"}
par(mfrow=c(2, 2))
plot(fit)
```