Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In R, enter the following commands to access on old dataset: > library(datasets)

ID: 3298917 • Letter: I

Question

In R, enter the following commands to access on old dataset: > library(datasets) > attach(cars) You will now have a variable called cars in your R session which is a data frame containing data showing the speed (mph) and stopping distance (ft) of 50 cars from the 1920s. (a) Using R. fit a simple linear regression model of distance on speed using these data. (b) Plot the data arid regression line together. Does the linear model seem appropriate? (c) Find 95% confidence intervals for the regression coefficients. (d) Give a 95% confidence interval for the mean stopping distance of a car travelling at 22 mph. (e) Give a 95% prediction interval for the stopping distance of a car travelling at 22 mph. (f) Are the usual regression model assumptions appropriate? Answer by reporting two appropriate diagnostic plots and commenting on them.

Explanation / Answer

solution a:

distance on speed

y on x

y---distance

x---speed

code:

mod1<- lm(dist ~speed,data=cars)

summary(mod1)

output:

Call:
lm(formula = dist ~ speed, data = cars)

Residuals:
Min 1Q Median 3Q Max
-29.069 -9.525 -2.272 9.215 43.201

Coefficients:
Estimate Std. Error t value
(Intercept) -17.5791 6.7584 -2.601
speed 3.9324 0.4155 9.464
Pr(>|t|)
(Intercept) 0.0123 *
speed 1.49e-12 ***

regression eq is

distance=-17.579+3.932(speed)

SOLUTIONB:

code:

scatter.smooth(x=cars$speed,y=cars$dist,main="Dist ~ Speed")

SolutionC:

Code:

confint(mod1, 'speed', level=0.95)

SolutionD:

code:

dist.lm = lm(dist ~speed,data=cars)
newdata = data.frame(speed=22)
predict(dist.lm, newdata, interval="confidence",level=0.95)

Solutione:

dist.lm = lm(dist ~speed,data=cars)
newdata = data.frame(speed=22)

predict(dist.lm, newdata, interval="predict",level=0.95)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote