plot.ts(austres, type="o")
M=c("diff",1)
e = Resid(austres,M)
test(e)
Null hypothesis: Residuals are iid noise.
Test Distribution Statistic p-value
Ljung-Box Q Q ~ chisq(20) 137.43 0 *
McLeod-Li Q Q ~ chisq(20) 40.76 0.004 *
Turning points T (T-57.3)/3.9 ~ N(0,1) 52 0.173
Diff signs S (S-43.5)/2.7 ~ N(0,1) 45 0.5818
Rank P (P-1914)/138.7 ~ N(0,1) 2321 0.0033 *
Augmented Dickey-Fuller Test
alternative: stationary
Type 1: no drift no trend
lag ADF p.value
[1,] 0 -4.63 0.0100
[2,] 1 -3.56 0.0100
[3,] 2 -2.49 0.0148
[4,] 3 -1.87 0.0625
Type 2: with drift no trend
lag ADF p.value
[1,] 0 -4.60 0.010
[2,] 1 -3.53 0.010
[3,] 2 -2.47 0.145
[4,] 3 -1.85 0.386
Type 3: with drift and trend
lag ADF p.value
[1,] 0 -4.85 0.0100
[2,] 1 -3.87 0.0195
[3,] 2 -2.71 0.2795
[4,] 3 -1.98 0.5786
----
Note: in fact, p.value = 0.01 means p.value <= 0.01
# since the non-stationary was not rejected. We need to do another differencing operator.
aTSA::adf.test(diff(e))
Augmented Dickey-Fuller Test
alternative: stationary
Type 1: no drift no trend
lag ADF p.value
[1,] 0 -12.80 0.01
[2,] 1 -10.54 0.01
[3,] 2 -8.92 0.01
[4,] 3 -6.35 0.01
Type 2: with drift no trend
lag ADF p.value
[1,] 0 -12.73 0.01
[2,] 1 -10.49 0.01
[3,] 2 -8.87 0.01
[4,] 3 -6.32 0.01
Type 3: with drift and trend
lag ADF p.value
[1,] 0 -12.65 0.01
[2,] 1 -10.42 0.01
[3,] 2 -8.81 0.01
[4,] 3 -6.28 0.01
----
Note: in fact, p.value = 0.01 means p.value <= 0.01
Null hypothesis: Residuals are iid noise.
Test Distribution Statistic p-value
Ljung-Box Q Q ~ chisq(20) 49.28 3e-04 *
McLeod-Li Q Q ~ chisq(20) 25 0.2015
Turning points T (T-56.7)/3.9 ~ N(0,1) 56 0.864
Diff signs S (S-43)/2.7 ~ N(0,1) 46 0.2679
Rank P (P-1870.5)/136.4 ~ N(0,1) 1917 0.7331
# Fit ARIMA(p,d=1,q)
a1=arima(x = austres,order = c(2,1,2))
test(a1$residuals)
Null hypothesis: Residuals are iid noise.
Test Distribution Statistic p-value
Ljung-Box Q Q ~ chisq(20) 26.56 0.148
McLeod-Li Q Q ~ chisq(20) 15.09 0.7714
Turning points T (T-58)/3.9 ~ N(0,1) 54 0.3096
Diff signs S (S-44)/2.7 ~ N(0,1) 45 0.715
Rank P (P-1958)/141.1 ~ N(0,1) 1966 0.9548
# Fit ARIMA(p,d=2,q)
a2=arima(x = austres,order = c(2,2,2))
test(a2$residuals)
Null hypothesis: Residuals are iid noise.
Test Distribution Statistic p-value
Ljung-Box Q Q ~ chisq(20) 14.64 0.7968
McLeod-Li Q Q ~ chisq(20) 17.71 0.6064
Turning points T (T-58)/3.9 ~ N(0,1) 58 1
Diff signs S (S-44)/2.7 ~ N(0,1) 47 0.2733
Rank P (P-1958)/141.1 ~ N(0,1) 2052 0.5053
# Fit ARIMA(p,d=1,q) - not iid
a3=arima(x = austres,order = c(1,1,0))
test(a3$residuals)
Null hypothesis: Residuals are iid noise.
Test Distribution Statistic p-value
Ljung-Box Q Q ~ chisq(20) 48.12 4e-04 *
McLeod-Li Q Q ~ chisq(20) 25.49 0.1834
Turning points T (T-58)/3.9 ~ N(0,1) 57 0.7995
Diff signs S (S-44)/2.7 ~ N(0,1) 47 0.2733
Rank P (P-1958)/141.1 ~ N(0,1) 1944 0.921
# Fit ARIMA(p,d=1,q) - not iid
a4=arima(x = austres,order = c(1,1,1))
test(a4$residuals)
Null hypothesis: Residuals are iid noise.
Test Distribution Statistic p-value
Ljung-Box Q Q ~ chisq(20) 32.2 0.0412 *
McLeod-Li Q Q ~ chisq(20) 13.49 0.8554
Turning points T (T-58)/3.9 ~ N(0,1) 52 0.1275
Diff signs S (S-44)/2.7 ~ N(0,1) 45 0.715
Rank P (P-1958)/141.1 ~ N(0,1) 2017 0.6758
# Fit ARIMA(p,d=2,q) - not iid
a5=arima(x = austres,order = c(1,2,0))
test(a5$residuals)
Null hypothesis: Residuals are iid noise.
Test Distribution Statistic p-value
Ljung-Box Q Q ~ chisq(20) 52.83 1e-04 *
McLeod-Li Q Q ~ chisq(20) 23.67 0.2571
Turning points T (T-58)/3.9 ~ N(0,1) 52 0.1275
Diff signs S (S-44)/2.7 ~ N(0,1) 45 0.715
Rank P (P-1958)/141.1 ~ N(0,1) 2049 0.5189
# Fit ARIMA(p,d=2,q)
a6=arima(x = austres,order = c(1,2,1))
test(a6$residuals)
Null hypothesis: Residuals are iid noise.
Test Distribution Statistic p-value
Ljung-Box Q Q ~ chisq(20) 26.65 0.1453
McLeod-Li Q Q ~ chisq(20) 13.52 0.8539
Turning points T (T-58)/3.9 ~ N(0,1) 56 0.6115
Diff signs S (S-44)/2.7 ~ N(0,1) 45 0.715
Rank P (P-1958)/141.1 ~ N(0,1) 2095 0.3315
# Fit ARIMA(p,d=2,q) = IMA(2,1)
a7=arima(x = austres,order = c(0,2,1))
test(a7$residuals)
Null hypothesis: Residuals are iid noise.
Test Distribution Statistic p-value
Ljung-Box Q Q ~ chisq(20) 28.67 0.0945
McLeod-Li Q Q ~ chisq(20) 12.84 0.8843
Turning points T (T-58)/3.9 ~ N(0,1) 54 0.3096
Diff signs S (S-44)/2.7 ~ N(0,1) 46 0.4652
Rank P (P-1958)/141.1 ~ N(0,1) 2108 0.2877
c(a1$aic,a2$aic,a6$aic,a7$aic)
[1] 668.2778 654.5503 654.4183 652.9911