In: Statistics and Probability
Please use R to solve this with explanation
Consider the simple linear trend model. This model relates quarterly sales (y) to time period (t).
a. Compute the residuals and plot them versus time.
b. Does the plot suggest that the error terms are autocorrelated? Explain.
c. Calculate the Durbin-Watson statistic.
d. Test for positive (first-order) autocorrelation = .05.
t |
Sales |
1 |
21.74 |
2 |
26.41 |
3 |
26.44 |
4 |
26.40 |
5 |
23.91 |
6 |
27.06 |
7 |
26.63 |
8 |
26.98 |
9 |
28.26 |
10 |
27.87 |
11 |
28.40 |
12 |
30.16 |
13 |
32.61 |
14 |
30.33 |
15 |
30.18 |
16 |
33.33 |
code for question number a and b are -
x=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
y=c(21.74,26.41,26.44,26.4,23.91,27.06,26.63,26.98,28.26,27.87,28.4,30.16,32.61,30.33,30.18,33.33)
l1=lm(y~x)
summary(l1)
t=resid(l1)
plot(x,t,abline(h=0))
output is-
Residuals:
Min 1Q Median 3Q Max
-2.0690 -0.8871 -0.1972 1.0447 2.1958
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 23.20700 0.73344 31.641 2.00e-14 ***
x 0.55440 0.07585 7.309 3.86e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.399 on 14 degrees of freedom
Multiple R-squared: 0.7924, Adjusted R-squared:
0.7775
F-statistic: 53.42 on 1 and 14 DF, p-value: 3.855e-06
from residual plot we can see that there is no presence of autocorrelation is here.