In: Statistics and Probability
Prediction: A common goal in regression is to use the estimated
model for prediction.
a) (1 points) Using your model from 2c, provide a highway driving
CO2 emissions prediction for vehicles that have a city CO2
emissions of 550. Show work by hand! You may validate with code
provided in R.
b) (1 point) A 2017 Ferrari California T has a city driving CO2
Emission of 550 and an observed highway driving CO2 Emission of
389. How far off is the predicted CO2 Emission from the observed
CO2 Emission for the Ferrari California T? In other words,
calculate the residual.
c) (1.5 points) Calculate the 95% confidence interval for the
predicted highway CO2 emissions for vehicles with 550 city CO2
emissions. Interpret.
d) (1.5 points) Calculate the 95% prediction interval for the
predicted highway CO2 emissions for the Ferrari California T.
Interpret.
e) (2 points) What is the mathematical and conceptual difference
between your answers in 2c and 2d?
Call:
lm(formula = HwyCO2 ~ CityCO2)
Residuals:
Min 1Q
Median 3Q
Max
-67.808 -14.695 -3.553 12.483 97.856
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 66.325785 3.411020
19.45 <2e-16 ***
CityCO2 0.577132
0.007082 81.50 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 23.79 on 846 degrees of freedom
Multiple R-squared: 0.887, Adjusted
R-squared: 0.8869
F-statistic: 6642 on 1 and 846 DF, p-value: < 2.2e-16
>
> # Plot the residuals for the analysis between CityCO2 and
HwyCO2
> plot(CityCO2, mod$residuals, main = "Residuals")
> abline(h = 0, lty =2, lwd = 2, col = "red")
>
> # Calculate the 95% CI for the slope.
> confint(mod, level = 0.95)
2.5 % 97.5 %
(Intercept) 59.6307299 73.0208405
CityCO2 0.5632321 0.5910317
>
> # Predict the Highway CO2 when City CO2 is 360.
> predict(mod, data.frame(CityCO2 = 550))
1
383.7483
>
> # Calculate a 95% confidence interval for when the Highway CO2
when City CO2 is 550.
> predict(mod, data.frame(CityCO2 = 550), interval =
"confidence", level = 0.95)
fit lwr
upr
1 383.7483 381.7781 385.7185
>
> # Calculate a 95% prediction interval for when the Highway CO2
when City CO2 is 550.
> predict(mod, data.frame(CityCO2 = 550), interval =
"prediction", level = 0.95)
fit lwr
upr
1 383.7483 337.0105 430.4861
>
We are predicting the highway CO2 emissions by using the city CO2 emissions
from the above R output, the fitted regression model is,
Highway CO2 = Intercept + coefficient * city CO2
Highway CO2 = 66.325785 + 0.577132 * city CO2
a) If a city CO2 emissions of 550.
then predicted highway CO2 emissions is,
Highway CO2 = 66.325785 + 0.577132 * 550
= 383.7484
Then a highway driving CO2 emissions is 383.7484
b) If observed emissions of CO2 is 550 and
actual emissions of city CO2 is 389
then the difference in predicted and actual value is,
Residual = observed value - fitted value
= 550 - 389
= 161
c) The 95% confidence interval when CO2 550 is,
from the above output,
lower confidence value = 381.7781
Upper confidence value = 385.7185
d) The 95% confidence interval for prediction of city CO2 is,
from the above output,
lower confidence value = 337.0105
Upper confidence value = 430.4861
>>>>>>>>>>>>>>>>>> Best Luck >>>>>>>>>>>>>>>