poil <- read.csv(url("http://research.stlouisfed.org/fred2/data/WCOILBRENTEU.csv"))
str(poil)
## '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 ...
summary(poil)
##          DATE          VALUE       
##  1987-05-15:   1   Min.   :  9.44  
##  1987-05-22:   1   1st Qu.: 18.37  
##  1987-05-29:   1   Median : 26.99  
##  1987-06-05:   1   Mean   : 44.87  
##  1987-06-12:   1   3rd Qu.: 67.86  
##  1987-06-19:   1   Max.   :141.07  
##  (Other)   :1493
head(poil)
##         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(poil)
##            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(poil, xlab=" Years", ylab="Price Per Barrel in Dollar", main="Price Trend of Per Barrel Oil in Dollar")

This figure shows the price trend of price of oil barrels in US Dollar. The figure shows that after 2004, oil price has been volatile. Now, constructing the log changes in price of oil is done to stationarize the data.

dlpoil <-diff(log(poil[,2]))
plot(poil[2:1499,1],dlpoil, xlab="Years", ylab="", main="Logarithmic Change in Oil Price")

The logarithmic changes in oil prices during the observation period are found mostly around zero except in some cases.

Auto-correlation function (ACF) and Partial Auto-correlation function (PACF) are studies in order to understand the relation between data over the periods of study.

acf(dlpoil, type="correlation", lag=250, xlab="lag",ylab="Correlations", main="ACF")

acf(dlpoil, type="partial", lag=250, xlab="lag",ylab="Correlations", main="PACF")

Basically, exponential deay of correlation occurs towards 0 for AR (p) model in the ACF plot and for MA(q) model in the PACF plot. Furthermore, 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 should occur. I didn’t observed such cutsoff. I have assumed that after 5 lag, there would be change in parttern.

MODEL IDENTIFICATIOB AND TEST FOR ADEQUACY

CONSTRUCTING AR(p)MODELS

AR(1)-AR(5) models are analyzed. Values of AIC and p-values are analyzed in order to examine the adequacy of models.

ar1 <- arima(dlpoil, order=c(1,0,0))
ar1
## 
## Call:
## arima(x = dlpoil, 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=4)

ar2 <- arima(dlpoil, order=c(2,0,0))
ar2
## 
## Call:
## arima(x = dlpoil, 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=4)

ar3 <- arima(dlpoil, order=c(3,0,0))
ar3
## 
## Call:
## arima(x = dlpoil, 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=4)

ar4 <- arima(dlpoil, order=c(4,0,0))
ar4
## 
## Call:
## arima(x = dlpoil, order = c(4, 0, 0))
## 
## Coefficients:
##          ar1      ar2     ar3      ar4  intercept
##       0.1899  -0.0219  0.0975  -0.0367     0.0004
## s.e.  0.0259   0.0263  0.0263   0.0260     0.0014
## 
## sigma^2 estimated as 0.001711:  log likelihood = 2645.93,  aic = -5279.86
tsdiag(ar4, gof.lag=4)

ar5 <- arima(dlpoil, order=c(5,0,0))
ar5
## 
## Call:
## arima(x = dlpoil, order = c(5, 0, 0))
## 
## Coefficients:
##          ar1      ar2     ar3      ar4    ar5  intercept
##       0.1901  -0.0225  0.0976  -0.0378  0.006     0.0004
## s.e.  0.0259   0.0264  0.0264   0.0265  0.026     0.0014
## 
## sigma^2 estimated as 0.001711:  log likelihood = 2645.96,  aic = -5277.92
tsdiag(ar5, gof.lag=4)

Ar(3) has lowest AIC value of -5279.88. For adequacy, I have also studies the p-values of Ljung Box Statistic, ACF of residuals and standardized residuals. In case of AR3, residual is closer to zero and p-values are higher mostly. This makes AR3 adequate.

CONSTRUCTING MA(q) MODELS

ma1 <- arima(dlpoil, order=c(0,0,1))
ma1
## 
## Call:
## arima(x = dlpoil, 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=4)

ma2 <- arima(dlpoil, order=c(0,0,2))
ma2
## 
## Call:
## arima(x = dlpoil, 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=4)

ma3 <- arima(dlpoil, order=c(0,0,3))
ma3
## 
## Call:
## arima(x = dlpoil, 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=4)

ma4 <- arima(dlpoil, order=c(0,0,4))
ma4
## 
## Call:
## arima(x = dlpoil, order = c(0, 0, 4))
## 
## Coefficients:
##          ma1     ma2     ma3      ma4  intercept
##       0.1906  0.0120  0.1011  -0.0025     0.0004
## s.e.  0.0259  0.0262  0.0269   0.0255     0.0014
## 
## sigma^2 estimated as 0.00171:  log likelihood = 2646.46,  aic = -5280.92
tsdiag(ma4, gof.lag=4)

ma5 <- arima(dlpoil, order=c(0,0,5))
ma5
## 
## Call:
## arima(x = dlpoil, order = c(0, 0, 5))
## 
## Coefficients:
##          ma1     ma2     ma3      ma4     ma5  intercept
##       0.1907  0.0125  0.1010  -0.0017  0.0038     0.0004
## s.e.  0.0260  0.0264  0.0269   0.0262  0.0248     0.0014
## 
## sigma^2 estimated as 0.00171:  log likelihood = 2646.47,  aic = -5278.94
tsdiag(ma5, gof.lag=4)

MA(3) model has lowest AIC value among 5 models estimated and is equal to -5282.91. Therefore, MA(3) the best model among all the MA models. Furthermore, p-values for Ljung Box Statistic, ACF or residuals and standardized residuals are studied. In case of MA(3) model, residuals are zero and p values are high. This makes AR(3) model best among others.

CONSTRUCTING ARMA(p,q) MODEL

For convenience, ARMA model is studied considering p and q as 1 and 2.

ar1ma1 <- arima(dlpoil, order=c(1,0,1))
ar1ma1
## 
## Call:
## arima(x = dlpoil, 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=4)

ar1ma2 <- arima(dlpoil, order=c(1,0,2))
ar1ma2
## 
## Call:
## arima(x = dlpoil, 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=4)

ar2ma1 <- arima(dlpoil, order=c(2,0,1))
ar2ma1
## 
## Call:
## arima(x = dlpoil, 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=4)

ar2ma2 <- arima(dlpoil, order=c(2,0,2))
ar2ma2
## 
## Call:
## arima(x = dlpoil, 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=4)

Among, all the studied models of ARMA(p,q) models, ARMA(2,2) has lowest AIC value of -5278.57. Similarly, inc case of ARMA(2,2) model, p-values are mostly high and residuals are zero. This makes ARMA(2,2) model best among other ARMA(p,q) models.

Thererefore, among all the studied models AR3, MA3 and ARMA(2,2) are adequate.