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

Solve the following in R (show your work). Consider a model for predicting the w

ID: 3048138 • Letter: S

Question

Solve the following in R (show your work).

Consider a model for predicting the weight in grams from the wing length (in millimeters) for a sample of Savannah sparrows found at Kent Island, New Brunswick, Canada. The data are in the file Sparrows.

So the first two lines in R should be:

library(Stat2Data)

data(Sparrows)

a. Is the slope of the least squares regression line for predicting Weight from Wing Length significantly different from zero? Show details to support your answer.

b. Construct and interpret a 95% confidence interval for the slope coefficient in this model.

c. Does your confidence interval in part (b) contain zero? How is this related to part (a)?

d. Find a 95% prediction interval for the weight of a Savannah sparrow with a wing length of 20 mm. (Solved: (7.884, 13.54))

e. Without using statistical software to obtain a new prediction interval, explain why a 95% prediction interval for the weight of a sparrow with a wing length of 25 mm would be narrower than the prediction interval in part (d).

Note that part d is already solved. It is included to aid with answering part e.

Explanation / Answer

SolutionA:'

library(Stat2Data)

data(Sparrows)

data(Sparrows)
head(Sparrows)
fit.lm <- lm( Weight ~WingLength , data=Sparrows)# fit a linear regression model
summary(fit) # show results

weight=y

wing length=x

output:

coefficients(fit.lm)#show coefficients

> coefficients(fit.lm)
(Intercept) WingLength
1.365490 0.467404

Regression eq

weight=1.365490 +0.467404 (WingLength )

summary(fit) # show results

Call:

lm(formula = WingLength ~ Weight, data = Sparrows)

Residuals:

Min 1Q Median 3Q Max

-7.1170 -1.4080 0.4279 1.3513 6.1457

Coefficients:

Estimate Std. Error t value Pr(>|t|)   

(Intercept) 8.75465 1.39601 6.271 6.62e-09 ***

Weight 1.31341 0.09756 13.463 < 2e-16 ***

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.346 on 114 degrees of freedom

Multiple R-squared: 0.6139, Adjusted R-squared: 0.6105

F-statistic: 181.3 on 1 and 114 DF, p-value: < 2.2e-16

Hypothesis:

Slope of regression line=0

Alternative hypothesis:

Slope of a regression line not =0

alpha=0.05

t=1slope/stderror

=1.31341/0.09756

=3.463

p= < 2e-16 ***

p<0.05

Reject Null hypothesis:

accept alternative hypothesis.

conclusion:

there is sufficient statistical evdience at 5% level of significance to conclude that

e slope of the least squares regression line for predicting Weight from Wing Length significantly different from zero

Solutionb:

confint(fit.lm, level=0.95)#gives 95% confidence interval

output:

2.5 % 97.5 %
(Intercept) -0.5309316 3.2619109
WingLength 0.3986288 0.5361792

95% confidence interval for slope of regression line is 0.3986288 and 0.5361792.
We are 95% confident that population slope of regression line lies in between 0.3986288 and 0.5361792.

Solutionc:

confidence interval does not contains zero.

it is above 0.4 and below 0.5

it supports the alternative hypothesis the slope of regression linear is nnot zero.

means weight and wing length are linearly dependent.

newdata = data.frame(WingLength=20) #predict for new datapoint

predict(fit.lm, newdata, interval="predict")

fit lwr upr
1 10.71357 7.883926 13.54321

ur answer is correct

Solutione:

As length increases slope value increases

hence prediction value increases.

predicted value for length=25 iis13.05059

hence with a wing length of 25 mm would be narrower than the prediction interval in parrt d and its value is

10.26151 and 15.83966