HW11

Cars

Using the “cars” dataset in R, build a linear model for stopping distance as a function of speed and replicate the analysis of your textbook chapter 3 (visualization, quality evaluation of the model, and residual analysis.)

Summary

\(\color{red}{\text{The residual lines appear to be normally distributed. The standard errors are at least 10 time smaller than the coefficient values. $\\$ This means there is little variability in the slope estimate. The very small Pr(>|t|) value shows the probability $\\$ that the values are NOT revelant. Result is they are revelant.}}\)

data("cars")

c.lm<-lm(cars$speed~cars$dist)

plot(cars$dist,cars$speed)
abline(c.lm)

summary(c.lm)
## 
## Call:
## lm(formula = cars$speed ~ cars$dist)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -7.5293 -2.1550  0.3615  2.4377  6.4179 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  8.28391    0.87438   9.474 1.44e-12 ***
## cars$dist    0.16557    0.01749   9.464 1.49e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.156 on 48 degrees of freedom
## Multiple R-squared:  0.6511, Adjusted R-squared:  0.6438 
## F-statistic: 89.57 on 1 and 48 DF,  p-value: 1.49e-12

\(\color{red}{\text{The fitted chart below shows the residuals uniformally scattered spread closely evenly throughout. $\\$ However, QQPlot shows that residuals are not normally distributed}}\)

plot(fitted(c.lm),resid(c.lm))

qqplot(fitted(c.lm),resid(c.lm))
qqline(fitted(c.lm),resid(c.lm))
## Warning in if (datax) {: the condition has length > 1 and only the first
## element will be used