Consider the weekly price for Brent Crude Oil, FRED/WCOILBRENTEU. Follow the Box-Jenkins methodology to build a time series model for log-change in the price:
examine the plot of the original data and for the log-change in the price
plot the ACF and the PACF for the log-change in the price
diagnose residuals for estimated model(s), if there are several competing specifications use AIC, BIC, Q statistics to compare their properties
In this problem data is analysed about Brent Crude oil weeekly price from May 1987 to January 2016.
The data for this proble is collectd from Quand.Quandl collected the data from Federal Reserve Economic Data website. The Crude oil price used in this anlayis is weekly data from May 1987 to January 2016.
oil <- read.csv(url("http://research.stlouisfed.org/fred2/data/WCOILBRENTEU.csv"))
str(oil)
## 'data.frame': 1499 obs. of 2 variables:
## $ DATE : Factor w/ 1499 levels "1987-05-15","1987-05-22",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ VALUE: num 18.6 18.5 18.6 18.7 18.8 ...
head(oil)
## DATE VALUE
## 1 1987-05-15 18.58
## 2 1987-05-22 18.54
## 3 1987-05-29 18.60
## 4 1987-06-05 18.70
## 5 1987-06-12 18.75
## 6 1987-06-19 19.01
tail(oil)
## DATE VALUE
## 1494 2015-12-25 35.90
## 1495 2016-01-01 36.55
## 1496 2016-01-08 34.19
## 1497 2016-01-15 29.10
## 1498 2016-01-22 27.76
## 1499 2016-01-29 31.75
plot(oil, xlab=" Years 1987-2016", ylab="Dollars per Barrel Not Seasonally Adjusted", main="Crude Oil Prices: Brent - Europe, Weekly")
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
The graphs shows the price of the oil has been highly volatile in recent years, especailly after 2004. After 2004, the price has reached it highest value till today.
dloil <-diff(log(oil[,2]))
plot(oil[2:1499,1],dloil, xlab="Years 1987-2016", ylab="", main="Log-change in oil price, Quaterly")
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
In the log difference plot, most of the change in log price are around zero. There are some weeks having larger price change, mostly on average the weekly change in price is homogenous.
acf(dloil, type="correlation", lag=200, xlab="Weekly lag",ylab="Correlations", main="Sample ACF")
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
acf(dloil, type="partial", lag=200, xlab="Weekly lag",ylab="Correlations", main="Sample PACF")
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
Typically, there is exponential deay of correlation towards zero for AR (p) model in the ACF plot and for MA(q) model in the PACF plot. Further, we could see cuts off after p lags in PACF plot for AR(p) model and cuts off after q lags in ACF plot for MA(q) model. In our sample data, we do not see exact cuts off. However, we can assume after 3 lag there is change in pattern with oscillation.
Lets look at AR(1), AR(2), and AR(3) model. We will check the adequecy of all there model inspecting AIC and residuals.
ar1 <- arima(dloil, order=c(1,0,0))
ar1
##
## Call:
## arima(x = dloil, order = c(1, 0, 0))
##
## Coefficients:
## ar1 intercept
## 0.1860 0.0004
## s.e. 0.0255 0.0013
##
## sigma^2 estimated as 0.001728: log likelihood = 2638.82, aic = -5271.65
tsdiag(ar1, gof.lag=50)
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
ar2 <- arima(dloil, order=c(2,0,0))
ar2
##
## Call:
## arima(x = dloil, order = c(2, 0, 0))
##
## Coefficients:
## ar1 ar2 intercept
## 0.1868 -0.0046 0.0004
## s.e. 0.0259 0.0259 0.0013
##
## sigma^2 estimated as 0.001728: log likelihood = 2638.84, aic = -5269.68
tsdiag(ar2, gof.lag=50)
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
ar3 <- arima(dloil, order=c(3,0,0))
ar3
##
## Call:
## arima(x = dloil, order = c(3, 0, 0))
##
## Coefficients:
## ar1 ar2 ar3 intercept
## 0.1865 -0.0214 0.0908 0.0004
## s.e. 0.0258 0.0263 0.0259 0.0014
##
## sigma^2 estimated as 0.001714: log likelihood = 2644.94, aic = -5279.88
tsdiag(ar3, gof.lag=50)
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
Among all three AR(p) model, AR(3) has lowest AIC , which is -5279.88. For aqeduacy, I inspecting the Standarized Residual plot, ACF of REsiduals plot, and P-values for Ljung-Box Statistic plot. In AR(1) and AR(2), the ACF residual is closer to zero for all lags and it has lower p-value for Ljung -Box stastistic after lag 2. In case of AR(3) ACF resiual is closer to zero and p-value for Ljung -Box stastistic is mostly higher. This indicats AR(3) is better model among three model presented above.
Lets look at MA(1), MA(2), and MA(3) model. We will check the adequecy of all there model inspecting AIC and residuals.
ma1 <- arima(dloil, order=c(0,0,1))
ma1
##
## Call:
## arima(x = dloil, order = c(0, 0, 1))
##
## Coefficients:
## ma1 intercept
## 0.1913 0.0004
## s.e. 0.0261 0.0013
##
## sigma^2 estimated as 0.001727: log likelihood = 2639.08, aic = -5272.16
tsdiag(ma1, gof.lag=50)
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
ma2 <- arima(dloil, order=c(0,0,2))
ma2
##
## Call:
## arima(x = dloil, order = c(0, 0, 2))
##
## Coefficients:
## ma1 ma2 intercept
## 0.1913 -0.0055 0.0004
## s.e. 0.0259 0.0261 0.0013
##
## sigma^2 estimated as 0.001727: log likelihood = 2639.1, aic = -5270.21
tsdiag(ma2, gof.lag=50)
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
ma3 <- arima(dloil, order=c(0,0,3))
ma3
##
## Call:
## arima(x = dloil, order = c(0, 0, 3))
##
## Coefficients:
## ma1 ma2 ma3 intercept
## 0.1908 0.0121 0.1017 0.0004
## s.e. 0.0258 0.0263 0.0263 0.0014
##
## sigma^2 estimated as 0.00171: log likelihood = 2646.45, aic = -5282.91
tsdiag(ma3, gof.lag=50)
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
Among all three MA(q) model, MA(3) has lowest AIC , which is -5282.91. For aqeduacy, I inspecting the Standarized Residual plot, ACF of REsiduals plot, and P-values for Ljung-Box Statistic plot. In MA(1) and MA(2), the ACF residual is closer to zero for all lags and it has lower p-value for Ljung -Box stastistic after lag 2. In case of MA(3) ACF resiual is closer to zero and p-value for Ljung -Box stastistic is mostly higher. This indicats MA(3) is better model among three model presented above.
Lets look at ARMA model with combinatio of p and q equals to 1 and 2. The inspection of model adequecy of all models is conducted assising AIC and residuals.
ar1ma1 <- arima(dloil, order=c(1,0,1))
ar1ma1
##
## Call:
## arima(x = dloil, order = c(1, 0, 1))
##
## Coefficients:
## ar1 ma1 intercept
## -0.2638 0.4484 0.0004
## s.e. 0.2169 0.2040 0.0012
##
## sigma^2 estimated as 0.001726: log likelihood = 2639.41, aic = -5270.82
tsdiag(ar1ma1, gof.lag=50)
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
ar1ma2 <- arima(dloil, order=c(1,0,2))
ar1ma2
##
## Call:
## arima(x = dloil, order = c(1, 0, 2))
##
## Coefficients:
## ar1 ma1 ma2 intercept
## 0.7339 -0.5416 -0.1061 0.0004
## s.e. 0.2114 0.2129 0.0568 0.0014
##
## sigma^2 estimated as 0.001724: log likelihood = 2640.53, aic = -5271.06
tsdiag(ar1ma2, gof.lag=50)
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
ar2ma1 <- arima(dloil, order=c(2,0,1))
ar2ma1
##
## Call:
## arima(x = dloil, order = c(2, 0, 1))
##
## Coefficients:
## ar1 ar2 ma1 intercept
## -0.5320 0.0884 0.7301 0.0004
## s.e. 0.1033 0.0363 0.0991 0.0013
##
## sigma^2 estimated as 0.00172: log likelihood = 2642.3, aic = -5274.59
tsdiag(ar2ma1, gof.lag=50)
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
ar2ma2 <- arima(dloil, order=c(2,0,2))
ar2ma2
##
## Call:
## arima(x = dloil, order = c(2, 0, 2))
##
## Coefficients:
## ar1 ar2 ma1 ma2 intercept
## 0.0279 0.3658 0.1687 -0.3635 0.0004
## s.e. 0.2081 0.0910 0.2099 0.1115 0.0014
##
## sigma^2 estimated as 0.001713: log likelihood = 2645.28, aic = -5278.57
tsdiag(ar2ma2, gof.lag=50)
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
## Warning in par("page"): "page" is not a graphical parameter
## Warning in plot_snapshot(incomplete_plots): Please upgrade R to at least
## version 3.0.2
aic.arma = c(ar1ma1$aic,ar1ma2$aic,ar2ma1$aic,ar2ma2$aic)
aic.arma
## [1] -5270.820 -5271.063 -5274.591 -5278.568
Among all four ARMA(p,q) model, ARMA(2,2) has lowest AIC , which is -5278.568. For aqeduacy, I inspecting the Standarized Residual plot, ACF of REsiduals plot, and P-values for Ljung-Box Statistic plot. In ARMA(1,1), the ACF residual is closer to zero for all lags and it has lower p-value for Ljung -Box stastistic after lag 1. In case of ARMA(1,2 and 2,1) ACF resiual is closer to zero and p-value for Ljung -Box stastistic is closer to zero after lag 2 and becomes higher adn lower over the next 50 lag as shown in the figure. The ARMA(2,2) model has higher p-value for Ljung -Box stastistic and lower ACF valuse, indicating ARMA(2,2) is better model among four model presented above.
Among all the models discussed above, AR(3), MA(3), and ARMA(2,2) are most adequate model.