Porsche Prices
Load Data
install.packages("Stat2Data")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.5'
## (as 'lib' is unspecified)
library("Stat2Data")
data("Cereal")
cereal = Cereal
a. Scatterplot
plot(cereal$Sugar, cereal$Calories)

The data appears to have a vaguely positive linear relationship
between Sugar and Calories in Cereal.
b. LSRL
attach(cereal)
## The following object is masked _by_ .GlobalEnv:
##
## Cereal
cereal.lm = lm(Calories~Sugar)
summary(cereal.lm)
##
## Call:
## lm(formula = Calories ~ Sugar)
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.428 -9.832 0.245 8.909 40.322
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 87.4277 5.1627 16.935 <2e-16 ***
## Sugar 2.4808 0.7074 3.507 0.0013 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 19.27 on 34 degrees of freedom
## Multiple R-squared: 0.2656, Adjusted R-squared: 0.244
## F-statistic: 12.3 on 1 and 34 DF, p-value: 0.001296
plot(Calories~Sugar)
abline(cereal.lm)

The LSRL for Sugar in Cereal according to Calories is y = 87.4277 +
2.4808x
c. Interpret Slope
For every increase in one gram of sugar, the predicted amount of
calories in the cereal increases by 2.4808 kCal.”
d. Predict 10 grams of Sugar
The fitted model would predict that for a cereal with 10 grams of
sugar, the total number of calories predicted is 112.2357 calories.
e. Size of Typical Error
The size of a typical error when predicting calories from sugar
content is 19.27.
f. Residuals Plot
Residual = Actual - Predicted
Residual = 110 - 89.9085
Residual = 20.0915
g. Residual Interpretation
The number of calories for just one gram of sugar in the Cherrios
cereal box is 20.0915 more than predicted.
h. Is the Lin Reg Model a good summary?
Scatterplot
plot(Calories~Sugar)
abline(cereal.lm)

The scatterplot shows a very slight linear, positive relationship
between number of Calories in a cereal box in relation to the number of
grams of sugar.
Plot of residuals vs fitted data
plot(cereal.lm$fitted.values, cereal.lm$residuals)
abline(0,0)

The residual plot shows no apparent pattern, indicating the linear
model is a good fit for the relationship between cereal calories and
sugar content.
Histogram of residuals
hist(cereal.lm$residuals, breaks = 10)

The histogram appears to be uni modal and roughly symmetric. Since
the residual plot for cereal sugar content and cereal calories is
roughly normally distributed, we have some confidence that a linear
model may fit the data best.
QQ Plot
qqnorm(cereal.lm$residuals)
qqline(cereal.lm$residuals)
#### The