# Problem 1. > da=read.table("m-dec19.txt",header=T) > d1=da[,2] > d9=da[,3] > out1=acf(d1,lag=24) > print(out1$acf,digit=1) [1,] 1.000 [2,] 0.225 [3,] -0.002 [4,] -0.076 [5,] -0.030 [6,] -0.022 [7,] -0.051 [8,] -0.050 [9,] -0.085 [10,] -0.079 [11,] -0.004 [12,] 0.076 [13,] 0.268 [14,] 0.018 [15,] -0.052 [16,] -0.092 [17,] -0.024 [18,] -0.042 [19,] -0.091 [20,] -0.080 [21,] -0.051 [22,] -0.058 [23,] -0.049 [24,] 0.053 [25,] 0.247 > out2=pacf(d1,lag=24) > print(out2$acf,digit=1) [1,] 0.225 [2,] -0.055 [3,] -0.067 [4,] 0.003 [5,] -0.020 [6,] -0.050 [7,] -0.032 [8,] -0.075 [9,] -0.056 [10,] 0.016 [11,] 0.060 [12,] 0.240 [13,] -0.106 [14,] -0.029 [15,] -0.057 [16,] -0.004 [17,] -0.047 [18,] -0.070 [19,] -0.035 [20,] -0.001 [21,] -0.048 [22,] -0.061 [23,] 0.037 [24,] 0.168 > Box.test(d1,lag=12,type='Ljung') Box-Ljung test data: d1 X-squared = 69.6524, df = 12, p-value = 3.72e-10 > tt=out1$acf[13]*sqrt(length(d1)) > tt [1] 5.637147 #Problem 2. > out1=acf(d9,lag=12) > print(out1$acf,digit=1) [1,] 1.000 [2,] 0.137 [3,] -0.062 [4,] -0.033 [5,] -0.059 [6,] -0.009 [7,] 0.003 [8,] -0.011 [9,] -0.078 [10,] -0.027 [11,] 0.043 [12,] -0.036 [13,] 0.005 > Box.test(d9,lag=12,type='Ljung') Box-Ljung test data: d9 X-squared = 16.8115, df = 12, p-value = 0.1568 #Problem 3. > da=read.table("m-cpileng.txt") > cpi=da[,4] > ct=diff(log(cpi))*100 > out=acf(ct,lag=12) > print(out$acf,digit=2) [1,] 1.00 [2,] 0.58 [3,] 0.60 [4,] 0.56 [5,] 0.50 [6,] 0.57 [7,] 0.55 [8,] 0.53 [9,] 0.56 [10,] 0.55 [11,] 0.56 [12,] 0.50 [13,] 0.50 > out=pacf(ct,lag=12) > print(out$acf,digit=1) [1,] 0.58 [2,] 0.39 [3,] 0.21 [4,] 0.07 [5,] 0.22 [6,] 0.16 [7,] 0.07 [8,] 0.12 [9,] 0.11 [10,] 0.12 [11,] -0.05 [12,] 0.01 > Box.test(ct,lag=12,type='Ljung') Box-Ljung test data: ct X-squared = 2186.646, df = 12, p-value < 2.2e-16 > out=acf(diff(ct),lag=12) > print(out$acf,digit=1) [1,] 1.000 [2,] -0.516 [3,] 0.062 [4,] 0.022 [5,] -0.147 [6,] 0.096 [7,] 0.008 [8,] -0.056 [9,] 0.042 [10,] -0.033 [11,] 0.100 [12,] -0.086 [13,] 0.042 > m1=arima(ct,order=c(1,0,5)) > m1 arima(x = ct, order = c(1, 0, 5)) Coefficients: ar1 ma1 ma2 ma3 ma4 ma5 intercept 0.9782 -0.8160 0.0652 -0.0997 -0.1062 0.1913 0.3247 s.e. 0.0094 0.0409 0.0511 0.0518 0.0478 0.0416 0.0755 sigma^2 estimated as 0.03388: log likelihood = 163.6, aic = -311.21 #Problem 4. > da=read.table("q-gnprate.txt") > gnp=da[,1] > m2=arima(gnp,order=c(3,0,0)) > m2 arima(x = gnp, order = c(3, 0, 0)) Coefficients: ar1 ar2 ar3 intercept 0.4172 0.2003 -0.1648 0.0168 s.e. 0.0636 0.0679 0.0642 0.0011 sigma^2 estimated as 9.313e-05: log likelihood = 769.83, aic = -1529.67 > p1=c(1,-m2$coef[1:3]) > roots=polyroot(p1) > roots [1] 1.542932+0.928342i -1.870974+0.000000i 1.542932-0.928342i > Mod(roots) [1] 1.800683 1.870974 1.800683 > kk=2*pi/acos(1.543/1.801) > kk [1] 11.59539 > mf=predict(m2,4) > names(mf) [1] "pred" "se" > print(mf$pred,digit=2) Time Series: Start = 240 End = 243 Frequency = 1 [1] 0.014 0.016 0.017 0.017 > print(mf$se,digit=2) Time Series: Start = 240 End = 243 Frequency = 1 [1] 0.0097 0.0105 0.0111 0.0111 #Problem 5. > m9=arima(d9,order=c(0,0,1)) > m9 arima(x = d9, order = c(0, 0, 1)) Coefficients: ma1 intercept 0.1593 0.0109 s.e. 0.0499 0.0029 sigma^2 estimated as 0.002700: log likelihood = 683.03, aic = -1360.07 > tsdiag(m9) > Box.test(m9$residuals,lag=12,type='Ljung') Box-Ljung test data: m9$residuals X-squared = 8.2257, df = 12, p-value = 0.7672 > mf=predict(m9,4) > print(mf$pred,digit=2) Time Series: Start = 445 End = 448 Frequency = 1 [1] 0.009 0.011 0.011 0.011 > print(mf$se,digit=2) Time Series: Start = 445 End = 448 Frequency = 1 [1] 0.052 0.053 0.053 0.053