The prediction is based on a multivariate linear regression with the following model:
mpg ~ wt + cyl + am + hp
where:
and the result is:
---
## Car Consumption Prediction
The prediction is based on a multivariate linear regression with the following model:
__mpg ~ wt + cyl + am + hp__
where:
* wt = Weight expressed in lb/1000
* cyl = Number of cylinders
* am = Transmission (0 = automatic, 1 = manual)
* hp = Gross horsepower
and the result is:
* mpg = Miles/(US) gallon
* lwr = The lower value of the confidence interval
* upr = The upper value of the confidence interval
fit <- lm(mpg ~ wt + cyl + am + hp, mpgData)
summary(fit)$coefficients
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 33.70832390 2.60488618 12.940421 7.733392e-13
## wt -2.49682942 0.88558779 -2.819404 9.081408e-03
## cyl6 -3.03134449 1.40728351 -2.154040 4.068272e-02
## cyl8 -2.16367532 2.28425172 -0.947214 3.522509e-01
## am1 1.80921138 1.39630450 1.295714 2.064597e-01
## hp -0.03210943 0.01369257 -2.345025 2.693461e-02
The intercept represents the estimated MPG for am0 (Automatic transmission). The adjusted R2^ how much variation is explained by the model and is better for multivariate regressions than its unadjusted version.
summary(fit)$adj.r.squared
## [1] 0.8400875
--- .class #id
## Regression Coefficients
```{r, echo=FALSE}
library(datasets)
mpgData <- mtcars[,c(1,2,4,6,9)]
mpgData$am <- factor(mpgData$am)
mpgData$cyl <- factor(mpgData$cyl)
```
```{r}
fit <- lm(mpg ~ wt + cyl + am + hp, mpgData)
summary(fit)$coefficients
```
The intercept represents the estimated MPG for am0 (Automatic transmission).
The adjusted R^2^ how much variation is explained by the model and is better for
multivariate regressions than its unadjusted version.
```{r}
summary(fit)$adj.r.squared
```
---
## Plotting the fit
```{r echo = FALSE, results = 'asis'}
par(mfrow = c(2,2))
plot(fit)
```
The Car Consumption Predictor app is hosted in shinyapps.io.
The source code can be found at Github.
---
## Thanks and links!
The Car Consumption Predictor app is hosted in [shinyapps.io](https://toxicafunk.shinyapps.io/carconsumption/).
The source code can be found at [Github](https://github.com/toxicafunk/datasciencecoursera/tree/master/DataProducts/project).
Thanks for your attention!
---
Car Consumption Prediction | 1 |
---|---|
Regression Coefficients | 2 |
Plotting the fit | 3 |
App Frontend | 4 |
Thanks and links! | 5 |
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |