**Data Set is in R Program using the package called faraway 1. Using the cheddar
ID: 3217780 • Letter: #
Question
**Data Set is in R Program using the package called faraway
1. Using the cheddar data:• (a) Fit a linear model with taste as the response and the other three variables as
predictors.
• (b) Suppose that the observations were taken in time order. Create a time variable.Plot the residuals of the model against time and comment on what can be seen.
• (c) Fit a GLS model with same form as above and allow for an AR(1) correlationamong the errors. Is there evidence of such a correlation?
• (d) Fit a OLS model but with time as an additional predictor. Investigate thesignicance of time in the model
Explanation / Answer
(a)
library(faraway)
data(cheddar)
x=cheddar
t=c(x[,1])
a=c(x[,2])
h=c(x[,3])
l=c(x[,4])
A=lm(t~a+h+l)
A
Call:
lm(formula = t ~ a + h + l)
Coefficients:
(Intercept) a h l
-28.8768 0.3277 3.9118 19.6705
(b)
tt=1:length(x[,1])
res=resid(A)
plot(tt,res,ylab="Residuals", xlab="Time",main="cheddar")
abline(0,0)
The scatterplots show no obvious patterns, although the residuals tend to be negative for large values of the time predictor.
For other question, R donot install GLS package.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.