Econ 5316 time Series Econometrics(Spring 2017) / Homework3 Problem2 (Feb.7)
Keunyoung(Kay) Kim
First, consider the quarterly Real PCE(Personal Consumption Expenditure). Second, construct the time series with log changes in Real PCE. Finally, estimate the model and evaluate it.
Data for the quarterly Real PCE is imported from Quandl website.(Quandle code : FED/PCECC96)
library(Quandl)
Quandl.api_key("XzdSwkDsE98Mxj3ixQzG")
rPCE <- Quandl("FRED/PCECC96", type="zoo" )
str(rPCE)
## 'zooreg' series from 1947 Q1 to 2016 Q4
## Data: num [1:280] 1199 1219 1223 1224 1230 ...
## Index: Class 'yearqtr' num [1:280] 1947 1947 1948 1948 1948 ...
## Frequency: 4
The plots for Real PCE are as following.
plot(rPCE, main="Real PCE")
Construct the time series with log changes in Real PCE (\(y_t\))
\[ y_t = \Delta log c_{t} = log c_{t} -log c_{t-1} \]
Denote the varialbe name for \(y_t\) by dlrPCE.
dlrPCE <- diff(log(rPCE))
plot(dlrPCE, main="Log changes in Real PCE")
Use ACF and PACF to identify suitable time series model.
library(forecast)
Acf(dlrPCE, type="correlation", lag=48, main="ACF for Real PCE")
Acf(dlrPCE, type="partial", lag=48, main="PACF for Real PCE")
If ACF dies out slowly and PACF drops to zero suddenly after lag p, then it is AR(p) model. If ACF drops to zero immediately after lag q and PACF dies out slowly, then is is MA(q) model.
In the figure above, however neither ACF nor PACF drop to zero abruptly. Therefore we need to consider ARMA model.
From PACF AR(2) or AR(4) can be candidates for the model and from ACF MA(2) also can be a candidate.Finally, we can combine the AR(2) and MA(2) for an ARMA(2,2) model.
Estimate them using Arima.
ar2 <- Arima(dlrPCE, order=c(2,0,0))
ar4 <- Arima(dlrPCE, order=c(4,0,0))
ma2 <- Arima(dlrPCE, order=c(0,0,2))
arma22 <- Arima(dlrPCE, order=c(2,0,2))
ar2; ar4; ma2; arma22
## Series: dlrPCE
## ARIMA(2,0,0) with non-zero mean
##
## Coefficients:
## ar1 ar2 intercept
## 0.0614 0.3185 0.0081
## s.e. 0.0566 0.0566 0.0007
##
## sigma^2 estimated as 5.955e-05: log likelihood=962.67
## AIC=-1917.34 AICc=-1917.2 BIC=-1902.82
## Series: dlrPCE
## ARIMA(4,0,0) with non-zero mean
##
## Coefficients:
## ar1 ar2 ar3 ar4 intercept
## 0.0585 0.3643 0.0243 -0.1442 0.0082
## s.e. 0.0593 0.0594 0.0594 0.0592 0.0007
##
## sigma^2 estimated as 5.87e-05: log likelihood=965.64
## AIC=-1919.28 AICc=-1918.97 BIC=-1897.5
## Series: dlrPCE
## ARIMA(0,0,2) with non-zero mean
##
## Coefficients:
## ma1 ma2 intercept
## 0.0277 0.3652 0.0082
## s.e. 0.0564 0.0581 0.0006
##
## sigma^2 estimated as 5.878e-05: log likelihood=964.46
## AIC=-1920.92 AICc=-1920.78 BIC=-1906.4
## Series: dlrPCE
## ARIMA(2,0,2) with non-zero mean
##
## Coefficients:
## ar1 ar2 ma1 ma2 intercept
## 0.1910 -0.0330 -0.1359 0.3911 0.0082
## s.e. 0.1572 0.1798 0.1442 0.1696 0.0007
##
## sigma^2 estimated as 5.888e-05: log likelihood=965.22
## AIC=-1918.45 AICc=-1918.14 BIC=-1896.66
AIC
The model that has the smallest AIC(in small samples) or BIC(in large samples) values is preferred. The number of data is 280 and this is small, so AIC is useful to assess the models.
From the results above, the MA(2) model has the smallest AIC value, -1920.92, therefore it suggests that an MA(2) model is preferred by the criterion.
BIC
From the results above, the MA(2) model has the smallest BIC value, -1906.39, therefore it suggests that an MA(2) model is preferred by the criterion.
To sum up, MA(2) which has the smallest values is preferred based on both AIC, and BIC.
AIC(ar2, ar4, ma2, arma22)
## df AIC
## ar2 4 -1917.343
## ar4 6 -1919.283
## ma2 4 -1920.922
## arma22 6 -1918.447
BIC(ar2, ar4, ma2, arma22)
## df BIC
## ar2 4 -1902.818
## ar4 6 -1897.495
## ma2 4 -1906.397
## arma22 6 -1896.660
Plot inverted AR and MA roots
plot.Arima(ar2)
plot.Arima(ar4)
plot.Arima(ma2)
plot.Arima(arma22)
If time series can be represented as a finite order moving average process, it is stationary. If time series can be represented as a finite order autoregressive process, it is invertible.
A causal invertible model should have all the roots outside the unit circle. Equivalently, the inverse roots should lie inside the unit circle.
From the figures above, all the inverse roots from four models lie inside the unit circle. Thus this time series are adequate.
The results below plot the standardized residuals, the autocorrelation function of the residuals, and the p-values of a Portmanteau test for all lags.
The residuals look like stationary except early 1950’s. The p-values for Ljung-Box Q statistics show that we can not reject the null hypothesis(no autocorrelation in residuals) except AR(2) model.
tsdiag(ar2, gof.lag=24)
tsdiag(ar4, gof.lag=24)
tsdiag(ma2, gof.lag=24)
tsdiag(arma22, gof.lag=24)
Q-statistics : Portmanteau’ tests
The Portmanteau(Box-Pierce or Ljung-Box) test examines the null of independently distributed residuals. It’s derived from the idea that the residuals of a “correctly specified” model are independently distributed. If the residuals are not, then they come from a miss-specified model.Based on the results below, the null hypothesis cannot be rejected(p-values are larger than 0.1). Therfore we can say that there are no autocorrelation in time series residuals, as we can see that in above analysis for residuals.
ar2.LB.lag2 <- Box.test(ar2$residuals, lag=2, type="Ljung")
ar4.LB.lag2 <- Box.test(ar4$residuals, lag=4, type="Ljung")
ma2.LB.lag2 <- Box.test(ma2$residuals, lag=2, type="Ljung")
arma22.LB.lag2 <- Box.test(arma22$residuals, lag=2, type="Ljung")
ar2.LB.lag2; ar4.LB.lag2; ma2.LB.lag2; arma22.LB.lag2
##
## Box-Ljung test
##
## data: ar2$residuals
## X-squared = 0.58389, df = 2, p-value = 0.7468
##
## Box-Ljung test
##
## data: ar4$residuals
## X-squared = 0.11817, df = 4, p-value = 0.9983
##
## Box-Ljung test
##
## data: ma2$residuals
## X-squared = 0.23634, df = 2, p-value = 0.8885
##
## Box-Ljung test
##
## data: arma22$residuals
## X-squared = 0.0010063, df = 2, p-value = 0.9995
From the ACF and PACF, four time series models are considered. To choose preferred model, we examine the adequacy and diagnose residuals. These models are adequate and very similar properties base don ACF, PACF and Q statistics for residuals.So information criteria is used to decide which one is preferred. As a result, MA(2) is more proper when it is compared to other three models, AR(2), AR(4) and ARMA(2,2).