The first step is to import the quarterly Real Personal Consumption Expenditures, FRED/PCECC96, as a ts object using Quandl packages.
rPCE <- Quandl("FRED/PCECC96", type="ts")
The next step is to construct a new time series \(y_{t}\) defined as the log changes of Real Personal Consumption Expenditures, \(y_{t}= \Delta \log{c_{t}} = \log{c_{t}} = \log{c_{t-1}}\), where \(c_{t}\) is the original quarterly Real Personal Consumption Expenditures, we can implement the calculation in R using the following code:
yt <- diff(log(rPCE), differences=1)
The following figures shows the original time series of \(c_{t}\) and the first difference of \(\log{c_{t}}\).
plot(rPCE, xlab="", ylab="Billions of Chained 2009 Dollars", main="Real Personal Consumption Expenditures")
plot(yt, xlab="", ylab="", main="Log-change in Personal Consumption Expenditures")
To identify the AR specification of the log changes of Real Personal Consumption Expenditures, \(y_{t}\), we have to plot the ACF and PACF for \(y_{t}\).
From the ACF, the dampened sine wave shape indicate an AR(\(p\)) process. We can further identify from PACF, that we have a significant lag in lag 2 and 4, and quite large (although borderline insignificant) PACF for lag 1. From our identification of PACF, we’ll estimate and evaluate the adequacy for AR(1), AR(2), AR(3) and AR(4).
Estimation of AR(1) model:
ar1 <- arima(yt, order=c(1,0,0))
Now, we’ll conduct post-estimation inspection of the residuals and model adequacy for AR(1)
tsdiag(ar1, gof.lag=12)
Based on the plots above, AR(1) model is inadequate, some serial correlation in the ACF of residuals are significant, this is in addition to extremely low \(p\)-values for Ljung-Box statistics for all except one lag.
Estimation of AR(2) model:
ar2 <- arima(yt, order=c(2,0,0))
Now, we’ll conduct post-estimation inspection of the residuals and model adequacy for AR(2)
tsdiag(ar2, gof.lag=12)
Based on the plots above, AR(2) model is slightly better that AR(1). However, we still have one significant lag in the ACF of residuals (lag 2), and eventhough we have higher \(p\)-values for Ljung-Box statistics on some lags, but we still have low \(p\)-values from lag 8 onward.
Estimation of AR(3) model:
ar3 <- arima(yt, order=c(3,0,0))
Now, we’ll conduct post-estimation inspection of the residuals and model adequacy for AR(3)
tsdiag(ar3, gof.lag=12)
Based on the plots above, AR(3) post-estimation diagnostic is no better that AR(2) estimation.
Estimation of AR(4) model:
ar4 <- arima(yt, order=c(4,0,0))
Now, we’ll conduct post-estimation inspection of the residuals and model adequacy for AR(4)
tsdiag(ar4, gof.lag=12)
Based on the plots above, AR(4) performs better that previous estimations.
We can also confirm our finding by simple AIC comparison between alternative specification.
ar <- ar(yt, method="mle")
ar$order
## [1] 4
ar$aic
## 0 1 2 3 4 5
## 29.5898061 29.3905747 1.8742608 3.8053769 0.0000000 1.9999836
## 6 7 8 9 10 11
## 2.8643601 1.8839187 1.6397094 1.8639941 0.5695805 2.5608319
## 12
## 1.1372523
We can see that AR(4) register the lowest AIC, hence AR(4) is the most adequate model for log-change in Personal Consumption Expenditures.
From previous ACF plot of log-change in Personal Consumption Expenditures, we are potentially dealing with MA(2). However, in this part we’ll estimate and check the adequacy of MA(1), MA(2), and MA(3) specification and select the specification that gives the best adequacy.
Estimation of MA(1) model:
ma1 <- arima(yt, order=c(0,0,1))
Now, we’ll conduct post-estimation inspection of the residuals and model adequacy for MA(1)
tsdiag(ma1, gof.lag=12)
Based on the plots above, MA(1) model is inadequate, some serial correlation in the ACF of residuals are significant, this is in addition to extremely low value \(p\)-values for Ljung-Box statistics for all except one lag.
Estimation of MA(2) model:
ma2 <- arima(yt, order=c(0,0,2))
Now, we’ll conduct post-estimation inspection of the residuals and model adequacy for MA(2)
tsdiag(ma2, gof.lag=12)
Based on the plots above, MA(2) model is far more adequate compared to MA(1), with none of the serial correlation in the ACF of residuals are significant, this is in addition to extremely high \(p\)-values for Ljung-Box statistics in comparison to MA(1).
Estimation of MA(3) model:
ma3 <- arima(yt, order=c(0,0,3))
Now, we’ll conduct post-estimation inspection of the residuals and model adequacy for MA(3)
tsdiag(ma3, gof.lag=12)
Based on the plots above, MA(3) model is more or less as adequate as MA(2). To pick the most adequate specification we have to conduct AIC and BIC comparison.
We conduct AIC comparison between alternative specifications using the code below:
AIC(ma1)
## [1] -1857.783
AIC(ma2)
## [1] -1889.769
AIC(ma3)
## [1] -1889.209
From the AIC comparison, we can see that MA(2) is by far the most adequate specification by a very slim margin. In order to have a more convincing comparison, we’ll also compare the BIC between the alternative specifications.
We conduct BIC comparison between alternative specifications using the code below:
BIC(ma1)
## [1] -1846.933
BIC(ma2)
## [1] -1875.302
BIC(ma3)
## [1] -1871.125
We can see that BIC information confirm our finding from AIC comparison. MA(2) is the most adequate specification for log-change in Personal Consumption.
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.