We consider the quarterly Real Personal Consumption Expenditure from the FRED Database. We first construct the time series using:
\[y_t = log c_t - log c_{t-1} \]
Our \(c_t\) value is the original quarterly Real Personal Consumption Expenditure.
library(Quandl)
rGDP<-Quandl("FRED/PCECC96", type="ts")
logrGDP<-log(rGDP)
lagdiff<-diff(logrGDP,1)
plot(lagdiff,xlab="Time", ylab="yt")
We graph the time series \(y_t = log c_t - log c_{t-1}\) and next we should examine the ACF and PACF of the differenced data to determine which models should be used for our estimation.
acf(as.data.frame(lagdiff),type='correlation',lag=24)
It looks as though AR(2), AR(3), and AR(4) can all be plausible from looking at the ACF.
acf(as.data.frame(lagdiff),type='partial',lag=24, main="")
The PACF seems to make a strong case for AR(4). From here, we should use the Ljung-Box statistic to see whether AR(4) makes sense.
AR4 <- arima(lagdiff, order=c(4,0,0))
tsdiag(AR4,gof.lag=24)
After looking at AR(1)-AR(4), it seems that our AR(4) model might be the answer we are looking for. Its residuals most resemble white noise.
Next we examine our statistic values.
## ar1 ar2 ar3 ar4 intercept
## 3.393510e-01 1.076861e-09 6.835508e-01 1.545290e-02 0.000000e+00
We can see that our AR(4) model is significant.
As another measure of confirmation, we can also look at ML to see if it confirms our AR(4) model.
ml <- ar(lagdiff,method="mle")
ml
##
## Call:
## ar(x = lagdiff, method = "mle")
##
## Coefficients:
## 1 2 3 4
## 0.0570 0.3647 0.0244 -0.1444
##
## Order selected 4 sigma^2 estimated as 5.84e-05
Indeed it does confirm our AR(4) model.
In our MA model, we use variations of the following code to look at MA(1)-MA(4) models.
MA2 <- arima(lagdiff, order=c(0,0,2))
tsdiag(MA2,gof.lag=24)
It seems that our MA(2) model is the only one that is significant. All of our other models do not have residuals that resemble white noise.