We consider weekly prices for Brent Crude from the FRED Database. We first construct the time series using:
\[y_t = log crude_t - log crude_{t-1} \]
Our \(crude_t\) value is the weekly price for Brent Crude.
library("Quandl")
oil<-Quandl("FRED/WCOILBRENTEU", type="zoo")
logoil<-log(oil)
diffoil<-diff(logoil,1)
plot(diffoil,xlab="Time", ylab="Oil_diff")
We graph the time series \(y_t = log crude_t - log crude_{t-1}\) and the differences do suggest stationarity. Next we should examine the ACF and PACF of the differenced data to determine which models should be used for our estimation.
acf(diffoil,type='correlation',na.action=na.pass,lag=52)
It looks as though AR(3) is the correct estimate. Lets also look at the ACF.
acf(diffoil,type='partial',na.action=na.pass,lag=52)
The PACF seems to make a strong case for AR(3). From here, we should use the Ljung-Box statistic to see whether AR(3) makes sense.
AR3 <- arima(diffoil, order=c(3,0,0))
tsdiag(AR3,gof.lag=24)
AR4 <- arima(diffoil, order=c(4,0,0))
tsdiag(AR4,gof.lag=24)
After looking at AR(2)-AR(4), it seems that both our AR(3) and AR(4)) model might be the answer we are looking for. Its residuals most resemble white noise. However, can we narrow it down?
Next we examine our statistic values.
## ar1 ar2 ar3 intercept
## 5.089262e-13 4.147876e-01 4.635997e-04 8.025994e-01
## ar1 ar2 ar3 ar4 intercept
## 2.358114e-13 4.036114e-01 2.159524e-04 1.590156e-01 7.947643e-01
We see that our AR(4) term is not very significant. It does look like AR(3) is a better estimate.
As another measure of confirmation, we can also look at ML to see if it confirms our AR(3) model.
ml <- ar(diffoil,method="mle")
ml$order
## [1] 3
ml$aic
## 0 1 2 3 4 5
## 58.65511115 8.25179485 10.21985289 0.00000000 0.01379955 1.96140525
## 6 7 8 9 10 11
## 2.66597859 3.62011691 5.61305200 7.47928172 6.33484440 6.35000890
## 12
## 8.23251917
Indeed it does confirm our AR(3) model since it has the lowest AIC value.
BIC(AR3)
## [1] -5253.322
BIC(AR4)
## [1] -5247.993
Our BIC test also shows that AR(3) is a better estimate since the BIC is lower than AR(3)