In: Math
Use R studio to do this problem. This problem uses the wblake data set in the alr4 package. This data set includes samples of small mouth bass collected in West Bearskin Lake, Minnesota, in 1991. Interest is in predicting length with age. Finish this problem without using Im()
(a) Compute the regression of length on age, and report the estimates, their standard errors, the value of the coefficient of determination, and the estimate of variance. Write a sentence or two that summarizes the results of these computations
(b) Obtain a 99% confidence interval for from the data. Interpret this interval in the context of the data.
(c) Obtain a prediction and a 99% prediction interval for a small mouth bass at age 1 . Interpret this interval in the context of the data.
----------------------------------------------------------------------------------------------------------------
R output:
Code in text format:
# install.packages("alr4")
library(alr4)
data(wblake)
names(wblake)
# Part (a) solution:
X = wblake$Age; Y = wblake$Length
xbar = mean(X); ybar = mean(Y); n = length(Y)
SSxy = sum((X-xbar)*(Y-ybar))
SSxx = sum((X-xbar)^2); SSyy = sum((Y-ybar)^2)
(b1 = SSxy/SSxx); (b0 = ybar-b1*xbar) # Reg Estimates
Y.hat = b0+b1*X # Reg of length on age
SSE = sum((Y-Y.hat)^2); SSR = sum((Y.hat-ybar)^2); SST =
SSR+SSE
(R.Sq = SSR/SST) # Coefficient of Deter
(MSE = SSE/(n-2)) # Estimate of Variance
(SE.b1 = sqrt(MSE/SSxx)) # SE of slope b1
(SE.b0 = sqrt(MSE*((1/n)+(xbar^2/SSxx)))) # SE of intercept b0
#------------------------------------------------------------------------
#
# Part (b) solution:
# Calculate a 99% confidence interval for beta1.
a = 1-0.99 # Confidence level = 0.99
t.star = round(qt(1-a/2,n-2),3) # t critical value
ME = t.star*SE.b1
b1-c(ME,-ME) # 99% CI for beta1
#-------------------------------------------------------------------------
#
# Part(c) solution:
# Cal a prection and a 99% preidction interval for a small mouth at
age 1
x0 = 1
(Y.Pred = b0+b1*x0) # Predicted Y when X=1
ME = t.star*sqrt(MSE)*sqrt(1+(1/n)+((x0-xbar)^2)/SSxx)
Y.Pred - c(ME,-ME)