The first step is to import the weekly price for Brent Crude Oil, FRED/WCOILBRENTEU, using Quandl packages.
BCO <- Quandl("FRED/WCOILBRENTEU", type="zoo")
str(BCO)
'zoo' series from 1987-05-15 to 2016-01-29
Data: num [1:1499] 18.6 18.5 18.6 18.7 18.8 ...
Index: Date[1:1499], format: "1987-05-15" "1987-05-22" "1987-05-29" "1987-06-05" ...
The next step is to construct a new time series \(LBCO_{t}\) defined as the log changes of the weekly price for Brent Crude Oil, \(LBCO_{t}= \Delta \log{BCO_{t}} = \log{BCO_{t}} - \log{BCO_{t-1}}\), where \(BCO_{t}\) is the original weekly price for Brent Crude Oil, we can implement the calculation in R using the following code:
LBCO <- diff(log(BCO), differences=1)
The following figures shows the original time series of \(BCO_{t}\) and the first difference of \(\log{BCO_{t}}\).
plot(BCO, xlab="", ylab="Dollars per Barrel, Not Seasonally Adjusted", main="Weekly Price for Brent Crude Oil")
plot(LBCO, xlab="", ylab="", main="Log-change in Weekly Price for Brent Crude Oil")
To identify the AR and MA specification of the log changes of the weekly price for Brent Crude Oil, \(LBCO_{t}\), we have to plot the ACF and PACF for \(LBCO_{t}\).
From the plot of ACF and PACF above, we can see that ACF drops to zero immediately after lag 3, while PACF shows an oscilating decay. Hence, we’re potentially dealing with MA(3) specification. In the next part, we’ll estimate MA(3) and compared the post-estimation diagnostic, Q-statisctics/Ljung-Box Statistics, AIC, and BIC with alternative specification of MA(1), MA(2), and MA(4).
Estimation of MA(3) model:
ma3 <- arima(LBCO, order=c(0,0,3))
Now, we’ll conduct post-estimation inspection of the residuals and model adequacy for MA(1)
tsdiag(ma3, gof.lag=12)
Based on the plots above, MA(3) specification is adequate. We can also test the specification further for adequacy using Ljung-Box test on the residuals. Given that we have 1499 observations, \(\log{T}\) is 7.312553 or approximately 7, we choose \(m=7\).
ma3.LB <- Box.test(ma3$residuals, lag=7, type="Ljung")
ma3.LB
##
## Box-Ljung test
##
## data: ma3$residuals
## X-squared = 0.85345, df = 7, p-value = 0.9969
Adjusting for the degree of freedom using the number of parameters estimated in our MA(3) model, i.e. \(g=3\), we will use critical values for \(\chi^2_{4}\) and calculate
pv <- 1-pchisq(ma3.LB$statistic,4)
pv
## X-squared
## 0.9311416
The \(p\)-values of 0.931 using adjusted degree of freedom above indicate the null hypotheses of no residual serial correlation in the first 7 lags is strongly not rejected, MA(3) specification is adequate.
To further scrutinize our result, we will estimate alternative specification of MA(1), MA(2), and MA(4).
Estimation of MA(1) model:
ma1 <- arima(LBCO, order=c(0,0,1))
tsdiag(ma1, gof.lag=12)
Based on the plots above, MA(1) model is inadequate, even though there is no signigicant serial correlation in the ACF of residuals, we have extremely low value \(p\)-values for Ljung-Box statistics for all except the first two lag.
Estimation of MA(2) model:
ma2 <- arima(LBCO, order=c(0,0,2))
tsdiag(ma2, gof.lag=12)
Based on the plots above, MA(2) model is also inadequate, the ACF of residuals shows the same pattern with MA(1). Even though there is no signigicant serial correlation in the ACF of residuals, we have extremely low value \(p\)-values for Ljung-Box statistics for all except the first two lag.
Estimation of MA(4) model:
ma4 <- arima(LBCO, order=c(0,0,4))
tsdiag(ma4, gof.lag=12)
Based on the plots above, MA(4) model is also a strong candidate for an adequate model. We can also test the specification further for adequacy using Ljung-Box test on the residuals with \(m=7\).
ma4.LB <- Box.test(ma4$residuals, lag=7, type="Ljung")
ma4.LB
##
## Box-Ljung test
##
## data: ma4$residuals
## X-squared = 0.82192, df = 7, p-value = 0.9972
Adjusting for the degree of freedom using the number of parameters estimated in our MA(4) model, i.e. \(g=4\), we will use critical values for \(\chi^2_{4}\) and calculate
pv <- 1-pchisq(ma3.LB$statistic,3)
pv
## X-squared
## 0.8366434
We can see that the \(p\)-values for MA(4) is actually quite high. However, it is actually still lower that MA(3) specification. Hence, MA(3) is still the most favorable specification for the log changes of the weekly price for Brent Crude Oil.
This can be further verified by AIC comparison of MA(1), MA(2), MA(3), and MA(4) as follow:
AIC(ma1)
## [1] -5272.164
AIC(ma2)
## [1] -5270.209
AIC(ma3)
## [1] -5282.91
AIC(ma4)
## [1] -5280.92
We can see that the AIC for MA(3) is the lowest. This conclusion also supported buy BIC comparison as follow:
BIC(ma1)
## [1] -5256.228
BIC(ma2)
## [1] -5248.961
BIC(ma3)
## [1] -5256.35
BIC(ma4)
## [1] -5249.049
From the comparison above we can see that BIC confirm our finding that MA(3) is the most adequate specification for the log changes of the weekly price for Brent Crude Oil.
From our initial identification using ACF and PACF, MA(3) is the most potential candidate for an adequate model specification for the log changes of the weekly price for Brent Crude Oil. We also found, that MA(4) also shows some indication for an adequate model. However, comparison on Q statistics shows that MA(3) is still favorable compared to MA(4). This conclusion also confirmed by the comparison of AIC and BIC for MA(1), MA(2), MA(3), and MA(4), where MA(3) has the lowest AIC and BIC.