Question: there are two questions about R studio below. here is R code is needed for homework. screenshot below shows questions. ###################################################### ### From KNNL 1.27.
there are two questions about R studio below.
here is R code is needed for homework. screenshot below shows questions.
######################################################
### From KNNL 1.27. A person's muscle mass is expected
### to decrease with age. To explore this relationship
### in women, a nutritionist randomly selected 15 women
### from each 10-year age group beginning with age 40
### and ending with age 79. The first column in the
### file is Y='measure of muscle mass'; the second
### column is X='age'.
######################################################
# read in the data from the file
MuscleData
#MuscleData
names(MuscleData) = c('Mass','Age')
# plot the data
plot(MuscleData$Age,MuscleData$Mass,ylab='Measure of muscle mass',xlab='Age')
# it appears that a straight line will fit the data fairly well.
# fit SLR model
Muscle.slr=lm(Mass~Age,data=MuscleData)
# easily plot the estimate regression line on the plot
abline(Muscle.slr)
# parameter estimates and tests
summary(Muscle.slr)
# ANOVA table and overall F-test
anova(Muscle.slr)
# the test for the slope parameter differing from 0 is highly, highly significant.
# What's a point estimator for sigma^2?
# You can get that from the summary() output: Square the "Residual standard error"
# You can also get that from the anova() output: Mean squared error
# What's the residual for the fifth observation?
Muscle.slr$residual[5]
# confidence intervals for the parameters (chapter 2, pp 1-2 of notes)
confint(Muscle.slr,,.95)
# confidence interval for just beta1 (i.e. the second parameter)
confint(Muscle.slr,c(2),.95)
# if you want to predict new values Age=60 ...
new=data.frame(Age=c(60));
predict(Muscle.slr,new)
# A confidence interval for the mean muscle mass value at Age=60
predict(Muscle.slr,new,interval="confidence")
# A prediction interval for the muscle mass of a woman at Age=60
predict(Muscle.slr,new,interval="prediction")

0. Go through the code, line by line, in the \"Lab3_SLR_more_inference.R\" file, which includes reading in the fitting the data in the CHO1PR27.txt file. 1. Find the observation with the largest residual (in absolute value). Turn in the value of this residual, the response value of the observation associated with this residual, and the fitted value for this observation. Hint: ?sort or ?max. (The purpose of this is to help you better understand what a residual is, and how to use R to perform computations associated with the data you are analyzing.) 2. Using R, construct a 90% CI for the true mean muscle mass at age 70 (so in this case, Xh = 70 and 3),, is the prediction at Xh). Then, construct a 90% PI for a new observation at age 70. the same response. Turn in the code and results. (To think about, but not turn in: Which interval is wider? Does this make sense?)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
