Analysis of Various Time Series Data Sets



Catagory A Time Series:
Industrial Production: Total index FRED/IPB50001SQ

## 'zooreg' series from 1919 Q1 to 2015 Q4
##   Data: num [1:388] 4.84 4.88 5.42 5.29 5.78 ...
##   Index: Class 'yearqtr'  num [1:388] 1919 1919 1920 1920 1920 ...
##   Frequency: 4



The plot of the original data appears to have an exponential trend. In addition, since this is data on industrial production, from an economic stand-point it makes sense to take the logarithm so we can get the percentage change per unit of time. This is an intuitive and interesting way to view and analyze this type of data.




The ACF and PACF suggest nonstationarity and the presence of deterministic or stochastic trend.

## 
##  Augmented Dickey-Fuller Test
## 
## data:  log_IPB50001SQ
## Dickey-Fuller = -2.1029, Lag order = 7, p-value = 0.5337
## alternative hypothesis: stationary


This initial basic Augmented Dickey-Fuller (ADF) Test suggests we Fail to Reject the null that this time series has a unit root.

Before we start the ADF testing we need to determine the appropriate lag length to select based on this time series data set. However, care must be taken to ensure that an appropriate lag length is chosen. If the lag length is too short then the residuals will be serially correlated and the test will be biased. If the lag length is too large the power of the test will suffer. There is some literate precedence to suggest, based on boot strapping the lag length, that erring on the side of too large is better than erring on the side of too short.

To get a staring point for \(p_{max}\) I will use a procedure developed by G. William Schwert in his 1989 paper in The Journal of Business of Economic Statistics.
\[{l_{12}} = {\mathop{\rm int}} \left\{ {12{{\left( {{T \over {100}}} \right)}^{{1 \over 4}}}} \right\}\]
This differs some from the suggestions by Said and Dickey but since I am only using this as a guide it seems reasonable to use.

Once a starting point has been determined, I will use this \(p_{max}\) value as my lag parameter and then plot the residuals of the ADF test to determine the appropriateness of the lag length. If the residuals appear correlated a larger lag value will be chosen. This process will continue until all serial correlation has disappeared. This process is more of an art form than a science but I feel like it is worth the time to ensure a proper lag length is determined.

After executing the above mentioned process, I have determined that a lag length of \(p_{max}=18\).

We will follow the “Proposed Full Procedure for ADF Test” guidelines to determine what type of difference stationary model we are dealing with.

# Model C
t1 <- ur.df(log_IPB50001SQ, type="trend", lags=18, selectlags = "Fixed")
plot(t1)

summary(t1)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.132072 -0.011228 -0.000389  0.011427  0.184274 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.950e-02  1.417e-02   2.081 0.038128 *  
## z.lag.1      -1.348e-02  9.136e-03  -1.475 0.141064    
## tt            1.065e-04  8.369e-05   1.273 0.204023    
## z.diff.lag1   6.120e-01  5.249e-02  11.660  < 2e-16 ***
## z.diff.lag2  -3.035e-01  6.102e-02  -4.973 1.04e-06 ***
## z.diff.lag3   4.447e-01  6.304e-02   7.054 9.46e-12 ***
## z.diff.lag4  -4.848e-01  6.698e-02  -7.239 2.92e-12 ***
## z.diff.lag5   2.228e-01  7.135e-02   3.122 0.001944 ** 
## z.diff.lag6  -1.141e-01  7.114e-02  -1.603 0.109797    
## z.diff.lag7   1.151e-01  6.993e-02   1.646 0.100661    
## z.diff.lag8  -1.754e-01  6.971e-02  -2.517 0.012296 *  
## z.diff.lag9   3.036e-01  6.831e-02   4.445 1.19e-05 ***
## z.diff.lag10 -2.477e-01  6.823e-02  -3.631 0.000325 ***
## z.diff.lag11  8.284e-02  6.809e-02   1.217 0.224557    
## z.diff.lag12 -1.542e-01  6.687e-02  -2.306 0.021726 *  
## z.diff.lag13  1.709e-01  6.615e-02   2.583 0.010204 *  
## z.diff.lag14 -4.511e-02  6.532e-02  -0.691 0.490334    
## z.diff.lag15 -2.577e-02  5.977e-02  -0.431 0.666649    
## z.diff.lag16  9.049e-02  5.586e-02   1.620 0.106179    
## z.diff.lag17 -8.682e-02  5.346e-02  -1.624 0.105245    
## z.diff.lag18 -5.143e-02  4.731e-02  -1.087 0.277760    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02979 on 348 degrees of freedom
## Multiple R-squared:  0.4135, Adjusted R-squared:  0.3798 
## F-statistic: 12.27 on 20 and 348 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -1.4752 4.4048 1.6011 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.98 -3.42 -3.13
## phi2  6.15  4.71  4.05
## phi3  8.34  6.30  5.36


We start by testing against Model C, \[\Delta {y_t} = \gamma {y_{t - 1}} + \mu + \beta t + \sum\limits_{i = 1}^{p - 1} {{p_i}} \Delta {y_{t - i}} + {e_t}\] where we look at the \(\phi_3\) statistic to test \(H_0:\) \(\gamma=\beta=0\)

According to the critical region we Fail to Reject the null which implies that this time series data set contains a unit root. This is further confirmed by looking at \(\tau_3\) statistic for the lagged endogenous variable in levels to see that we Fail to Reject the null that \(H_0:\) \(\gamma=0\). Again a unit root can not be rejected.

We next look at the \(\phi_2\) statistic to determine if this time series data is a random walk or a random walk with drift. The \(H_0: \gamma=\mu=\beta=0\) but since we have already determined that \(\gamma=\beta=0\) in previous hypothesis test we are really testing for \(\mu=0\). We find that we reject this hypnosis which indicates we are dealing with a Random Walk with Drift.

This can be further confirmed by now testing several hypothesis on Model B.

#Model B
t2 <- ur.df(log_IPB50001SQ, type="drift", lags=18, selectlags = "Fixed")
plot(t2)

summary(t2)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.131159 -0.010918  0.000188  0.011395  0.186482 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.013103   0.005910   2.217 0.027265 *  
## z.lag.1      -0.002035   0.001619  -1.257 0.209603    
## z.diff.lag1   0.606291   0.052342  11.583  < 2e-16 ***
## z.diff.lag2  -0.311719   0.060730  -5.133 4.75e-07 ***
## z.diff.lag3   0.437852   0.062869   6.965 1.65e-11 ***
## z.diff.lag4  -0.494206   0.066631  -7.417 9.18e-13 ***
## z.diff.lag5   0.217054   0.071267   3.046 0.002498 ** 
## z.diff.lag6  -0.123344   0.070828  -1.741 0.082484 .  
## z.diff.lag7   0.108756   0.069817   1.558 0.120202    
## z.diff.lag8  -0.183885   0.069451  -2.648 0.008472 ** 
## z.diff.lag9   0.298747   0.068265   4.376 1.60e-05 ***
## z.diff.lag10 -0.257196   0.067879  -3.789 0.000178 ***
## z.diff.lag11  0.076970   0.067991   1.132 0.258386    
## z.diff.lag12 -0.161232   0.066701  -2.417 0.016152 *  
## z.diff.lag13  0.165309   0.066066   2.502 0.012800 *  
## z.diff.lag14 -0.052471   0.065123  -0.806 0.420958    
## z.diff.lag15 -0.029361   0.059757  -0.491 0.623497    
## z.diff.lag16  0.084658   0.055726   1.519 0.129619    
## z.diff.lag17 -0.091899   0.053354  -1.722 0.085877 .  
## z.diff.lag18 -0.060413   0.046818  -1.290 0.197772    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02982 on 349 degrees of freedom
## Multiple R-squared:  0.4107, Adjusted R-squared:  0.3787 
## F-statistic:  12.8 on 19 and 349 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -1.257 5.7873 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.44 -2.87 -2.57
## phi1  6.47  4.61  3.79


Model B,

\[\Delta {y_t} = \gamma {y_{t - 1}} + \mu + \sum\limits_{i = 1}^{p - 1} {{p_i}} \Delta {y_{t - i}} + {e_t}\]
In Model B we first look at the \(\tau_2\) statistic under the null, \(H_0:\) \(\gamma=0\); Fail to Reject. Next we look at \(\phi_1\) statistic under the null \(H_0:\) \(\gamma=\mu=0\) which really means, based on the previous result, that we are testing if \(\mu=0\); Reject, which confirms again we are dealing with a Random Walk with Drift.

If we were suspecting we were dealing with a pure random walk model we could investigate Model A. Since we are satisfied we are dealing with a random walk with drift we will not look at Model A. However, we will look again at Model C to determine if differencing the series once I(1) will suffice or if we need to difference twice I(2).

# Model C Differenced Data
t3 <- ur.df(diff_log_IPB50001SQ, type="trend", lags=18, selectlags = "Fixed")
plot(t3)

summary(t3)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.127885 -0.010652  0.000275  0.010817  0.191369 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   9.847e-03  3.760e-03   2.619 0.009215 ** 
## z.lag.1      -8.758e-01  1.466e-01  -5.974 5.74e-09 ***
## tt           -1.459e-05  1.481e-05  -0.985 0.325275    
## z.diff.lag1   4.863e-01  1.410e-01   3.449 0.000632 ***
## z.diff.lag2   1.524e-01  1.374e-01   1.110 0.267965    
## z.diff.lag3   5.975e-01  1.331e-01   4.491 9.67e-06 ***
## z.diff.lag4   9.704e-02  1.311e-01   0.740 0.459758    
## z.diff.lag5   2.990e-01  1.253e-01   2.386 0.017565 *  
## z.diff.lag6   2.064e-01  1.221e-01   1.690 0.091914 .  
## z.diff.lag7   2.809e-01  1.139e-01   2.467 0.014093 *  
## z.diff.lag8   1.174e-01  1.100e-01   1.067 0.286771    
## z.diff.lag9   3.740e-01  1.024e-01   3.654 0.000298 ***
## z.diff.lag10  1.552e-01  1.004e-01   1.546 0.123089    
## z.diff.lag11  2.092e-01  9.072e-02   2.306 0.021685 *  
## z.diff.lag12  7.754e-02  8.598e-02   0.902 0.367758    
## z.diff.lag13  2.139e-01  7.841e-02   2.729 0.006685 ** 
## z.diff.lag14  1.942e-01  7.295e-02   2.663 0.008115 ** 
## z.diff.lag15  9.491e-02  6.297e-02   1.507 0.132664    
## z.diff.lag16  2.344e-01  6.028e-02   3.889 0.000121 ***
## z.diff.lag17  1.029e-01  5.219e-02   1.972 0.049439 *  
## z.diff.lag18  1.103e-01  4.665e-02   2.364 0.018636 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02962 on 347 degrees of freedom
## Multiple R-squared:  0.5267, Adjusted R-squared:  0.4994 
## F-statistic:  19.3 on 20 and 347 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -5.9741 11.9091 17.8519 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.98 -3.42 -3.13
## phi2  6.15  4.71  4.05
## phi3  8.34  6.30  5.36


Looking at the results from the above test we can conclude, by viewing the \(\tau_3\) statistic that we Reject the idea that we need to difference the data more than once. In other words, I(1) differencing is sufficient for this time series.

Testing to Fail to Reject the null is somewhat inappropriate. Since we had a Difference Stationary time series it would be better to use a test where the alternative is testing for Difference Stationarity. This is where the KPSS test come into play, which we will view next. In addition to the KPSS test we could present our differenced data to the testing under the ADF test which would then make our alternative hypnosis testing for Difference Stationary time series, which we did in the final step above but for a different reason.

As a final exercise I will show this at the end of the KPSS testing.

# KPSS Test - H0-Trend Stationary (tseries)
kpss.test(log_IPB50001SQ, null = "Trend")
## 
##  KPSS Test for Trend Stationarity
## 
## data:  log_IPB50001SQ
## KPSS Trend = 1.0812, Truncation lag parameter = 4, p-value = 0.01
# KPSS Test - H0-Level Stationary (tseries)
kpss.test(log_IPB50001SQ, null = "Level")
## 
##  KPSS Test for Level Stationarity
## 
## data:  log_IPB50001SQ
## KPSS Level = 7.6697, Truncation lag parameter = 4, p-value = 0.01


The p-values of the above KPSS tests is small which indicates we should reject the null that this is a Trend Stationary Series, further adding to the evidence that this time series has a unit root.

# KPSS Test - H0-Trend Stationary-mu (urca)
IPB_mu.kpss <- ur.kpss(log_IPB50001SQ, type = "mu")
summary(IPB_mu.kpss)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: mu with 5 lags. 
## 
## Value of test-statistic is: 6.4081 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.347 0.463  0.574 0.739
# KPSS Test - H0-Trend Stationary-tau (urca)
IPB_tau.kpss <- ur.kpss(log_IPB50001SQ, type = "tau")
summary(IPB_tau.kpss)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: tau with 5 lags. 
## 
## Value of test-statistic is: 0.9147 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.119 0.146  0.176 0.216


In the above KPSS test the critical values are well into the rejection region indicating this is not a trend stationary time series.

adf.test(diff_log_IPB50001SQ)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  diff_log_IPB50001SQ
## Dickey-Fuller = -8.0686, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary
# Model C
t1.diff <- ur.df(diff_log_IPB50001SQ, type="trend", lags=18, selectlags = "Fixed")
summary(t1.diff)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.127885 -0.010652  0.000275  0.010817  0.191369 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   9.847e-03  3.760e-03   2.619 0.009215 ** 
## z.lag.1      -8.758e-01  1.466e-01  -5.974 5.74e-09 ***
## tt           -1.459e-05  1.481e-05  -0.985 0.325275    
## z.diff.lag1   4.863e-01  1.410e-01   3.449 0.000632 ***
## z.diff.lag2   1.524e-01  1.374e-01   1.110 0.267965    
## z.diff.lag3   5.975e-01  1.331e-01   4.491 9.67e-06 ***
## z.diff.lag4   9.704e-02  1.311e-01   0.740 0.459758    
## z.diff.lag5   2.990e-01  1.253e-01   2.386 0.017565 *  
## z.diff.lag6   2.064e-01  1.221e-01   1.690 0.091914 .  
## z.diff.lag7   2.809e-01  1.139e-01   2.467 0.014093 *  
## z.diff.lag8   1.174e-01  1.100e-01   1.067 0.286771    
## z.diff.lag9   3.740e-01  1.024e-01   3.654 0.000298 ***
## z.diff.lag10  1.552e-01  1.004e-01   1.546 0.123089    
## z.diff.lag11  2.092e-01  9.072e-02   2.306 0.021685 *  
## z.diff.lag12  7.754e-02  8.598e-02   0.902 0.367758    
## z.diff.lag13  2.139e-01  7.841e-02   2.729 0.006685 ** 
## z.diff.lag14  1.942e-01  7.295e-02   2.663 0.008115 ** 
## z.diff.lag15  9.491e-02  6.297e-02   1.507 0.132664    
## z.diff.lag16  2.344e-01  6.028e-02   3.889 0.000121 ***
## z.diff.lag17  1.029e-01  5.219e-02   1.972 0.049439 *  
## z.diff.lag18  1.103e-01  4.665e-02   2.364 0.018636 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02962 on 347 degrees of freedom
## Multiple R-squared:  0.5267, Adjusted R-squared:  0.4994 
## F-statistic:  19.3 on 20 and 347 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -5.9741 11.9091 17.8519 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.98 -3.42 -3.13
## phi2  6.15  4.71  4.05
## phi3  8.34  6.30  5.36
# KPSS Test - H0-Trend Stationary (tseries)
kpss.test(diff_log_IPB50001SQ, null = "Trend")
## 
##  KPSS Test for Trend Stationarity
## 
## data:  diff_log_IPB50001SQ
## KPSS Trend = 0.031172, Truncation lag parameter = 4, p-value = 0.1
# KPSS Test - H0-Level Stationary (tseries)
kpss.test(diff_log_IPB50001SQ, null = "Level")
## 
##  KPSS Test for Level Stationarity
## 
## data:  diff_log_IPB50001SQ
## KPSS Level = 0.083126, Truncation lag parameter = 4, p-value = 0.1
# KPSS Test - H0-Trend Stationary-mu (urca)
IPB_mu.kpss.diff <- ur.kpss(diff_log_IPB50001SQ, type = "mu")
summary(IPB_mu.kpss.diff)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: mu with 5 lags. 
## 
## Value of test-statistic is: 0.0852 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.347 0.463  0.574 0.739
# KPSS Test - H0-Trend Stationary-tau (urca)
IPB_tau.kpss.diff <- ur.kpss(diff_log_IPB50001SQ, type = "tau")
summary(IPB_tau.kpss.diff)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: tau with 5 lags. 
## 
## Value of test-statistic is: 0.032 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.119 0.146  0.176 0.216


In the above ADF and KPSS tests where I passed the tests Differenced Data I received the results I expected. For the ADF tests the null was rejected and for the KPSS tests the null failed to be rejected.





Catagory B Time Series:
Shanghai Composite Index (China) YAHOO/INDEX_SSEC


str(INDEX_SSEC)
## 'zoo' series from 1997-07-02 to 2016-02-19
##   Data: num [1:4516] 1199 1151 1159 1097 1110 ...
##   Index:  Date[1:4516], format: "1997-07-02" "1997-07-03" "1997-07-04" "1997-07-07" ...



The above plot reflects the non-adjusted close of the Shanghai Composite Index for the time frame of 1997-07-02 until 2016-02-19 in daily frequency.

Based on this type of data it makes sense to take the logarithm of the data so we can look at the percent change in the index over time.




The ACF and PACF suggest nonstationarity and the presence of deterministic or stochastic trend.

I will follow the same procedure as above to analyze this time series data set.

According to Schwert model, a staring point for \(p_{max}\) = 32 lags.
\[{l_{12}} = {\mathop{\rm int}} \left\{ {12{{\left( {{T \over {100}}} \right)}^{{1 \over 4}}}} \right\}\]
The actual number of lags that seems to reduce all serial correlation in the residuals is 34 lags.

## 
##  Augmented Dickey-Fuller Test
## 
## data:  log_INDEX_SSEC
## Dickey-Fuller = -2.2493, Lag order = 16, p-value = 0.4728
## alternative hypothesis: stationary


According to this initial ADF Test we Fail to Reject the null that this is a Difference Stationary time series, indicating this time series may have a unit root.

# Model C
u1 <- ur.df(log_INDEX_SSEC, type="trend", lags=34, selectlags = "Fixed")
plot(u1)

summary(u1)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.093366 -0.007712  0.000314  0.007922  0.093897 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1.375e-02  6.048e-03   2.273 0.023057 *  
## z.lag.1      -1.877e-03  8.415e-04  -2.231 0.025760 *  
## tt            3.129e-07  2.513e-07   1.245 0.213162    
## z.diff.lag1   2.685e-02  1.498e-02   1.792 0.073151 .  
## z.diff.lag2  -2.993e-02  1.499e-02  -1.997 0.045849 *  
## z.diff.lag3   3.714e-02  1.499e-02   2.479 0.013229 *  
## z.diff.lag4   5.513e-02  1.500e-02   3.676 0.000239 ***
## z.diff.lag5   6.387e-03  1.500e-02   0.426 0.670320    
## z.diff.lag6  -5.074e-02  1.500e-02  -3.384 0.000722 ***
## z.diff.lag7   3.635e-02  1.501e-02   2.422 0.015487 *  
## z.diff.lag8  -6.504e-03  1.502e-02  -0.433 0.664934    
## z.diff.lag9  -3.167e-04  1.502e-02  -0.021 0.983180    
## z.diff.lag10 -2.160e-03  1.502e-02  -0.144 0.885619    
## z.diff.lag11  9.590e-03  1.502e-02   0.639 0.523165    
## z.diff.lag12  2.986e-02  1.502e-02   1.988 0.046844 *  
## z.diff.lag13  4.267e-02  1.502e-02   2.840 0.004531 ** 
## z.diff.lag14 -2.028e-02  1.506e-02  -1.347 0.178167    
## z.diff.lag15  4.943e-02  1.506e-02   3.282 0.001039 ** 
## z.diff.lag16  2.212e-03  1.507e-02   0.147 0.883319    
## z.diff.lag17  4.087e-03  1.507e-02   0.271 0.786300    
## z.diff.lag18  2.170e-02  1.507e-02   1.440 0.149935    
## z.diff.lag19 -2.043e-02  1.508e-02  -1.355 0.175412    
## z.diff.lag20  2.360e-02  1.506e-02   1.567 0.117239    
## z.diff.lag21 -1.175e-02  1.507e-02  -0.780 0.435689    
## z.diff.lag22  1.127e-02  1.507e-02   0.748 0.454673    
## z.diff.lag23 -2.842e-02  1.506e-02  -1.887 0.059278 .  
## z.diff.lag24  1.586e-02  1.507e-02   1.052 0.292678    
## z.diff.lag25 -1.616e-02  1.509e-02  -1.071 0.284052    
## z.diff.lag26 -2.505e-03  1.509e-02  -0.166 0.868167    
## z.diff.lag27 -1.493e-02  1.511e-02  -0.988 0.323261    
## z.diff.lag28  2.014e-02  1.511e-02   1.333 0.182532    
## z.diff.lag29  2.195e-02  1.509e-02   1.455 0.145873    
## z.diff.lag30 -2.068e-02  1.512e-02  -1.368 0.171355    
## z.diff.lag31 -9.399e-03  1.510e-02  -0.622 0.533821    
## z.diff.lag32 -3.316e-02  1.507e-02  -2.200 0.027867 *  
## z.diff.lag33 -6.559e-03  1.507e-02  -0.435 0.663437    
## z.diff.lag34  4.587e-02  1.505e-02   3.047 0.002325 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01638 on 4444 degrees of freedom
## Multiple R-squared:  0.02374,    Adjusted R-squared:  0.01583 
## F-statistic: 3.002 on 36 and 4444 DF,  p-value: 5.373e-09
## 
## 
## Value of test-statistic is: -2.2306 1.86 2.5313 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2  6.09  4.68  4.03
## phi3  8.27  6.25  5.34


We start by testing against Model C, \[\Delta {y_t} = \gamma {y_{t - 1}} + \mu + \beta t + \sum\limits_{i = 1}^{p - 1} {{p_i}} \Delta {y_{t - i}} + {e_t}\] where we look at the \(\phi_3\) statistic to test \(H_0:\) \(\gamma=\beta=0\)

According to the critical region we Fail to Reject the null which implies that this time series data set contains a unit root. This is further confirmed by looking at \(\tau_3\) statistic for the lagged endogenous variable in levels to see that we Fail to Reject the null that \(H_0:\) \(\gamma=0\). Again a unit root can not be rejected.

We next look at the \(\phi_2\) statistic to determine if this time series data is a pure random walk or a random walk with drift. The \(H_0: \gamma=\mu=\beta=0\) but since we have already determined that \(\gamma=\beta=0\) in previous hypothesis test we are really testing for \(\mu=0\). We find that we Fail to Reject this hypnosis which indicates we are dealing with a Pure Random Walk.

This can be further confirmed by now testing several hypothesis on Model B.

#Model B
u2 <- ur.df(log_INDEX_SSEC, type="drift", lags=34, selectlags = "Fixed")
plot(u2)

summary(u2)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.093568 -0.007620  0.000303  0.007907  0.093931 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.0092149  0.0048293   1.908 0.056436 .  
## z.lag.1      -0.0011877  0.0006338  -1.874 0.060991 .  
## z.diff.lag1   0.0264905  0.0149799   1.768 0.077061 .  
## z.diff.lag2  -0.0302983  0.0149845  -2.022 0.043238 *  
## z.diff.lag3   0.0367961  0.0149837   2.456 0.014097 *  
## z.diff.lag4   0.0547730  0.0149933   3.653 0.000262 ***
## z.diff.lag5   0.0060091  0.0150009   0.401 0.688745    
## z.diff.lag6  -0.0511219  0.0149953  -3.409 0.000657 ***
## z.diff.lag7   0.0359844  0.0150076   2.398 0.016538 *  
## z.diff.lag8  -0.0068682  0.0150146  -0.457 0.647380    
## z.diff.lag9  -0.0006861  0.0150196  -0.046 0.963569    
## z.diff.lag10 -0.0025268  0.0150142  -0.168 0.866362    
## z.diff.lag11  0.0092150  0.0150162   0.614 0.539465    
## z.diff.lag12  0.0295038  0.0150167   1.965 0.049507 *  
## z.diff.lag13  0.0422997  0.0150226   2.816 0.004888 ** 
## z.diff.lag14 -0.0206441  0.0150587  -1.371 0.170474    
## z.diff.lag15  0.0490566  0.0150583   3.258 0.001131 ** 
## z.diff.lag16  0.0018254  0.0150693   0.121 0.903592    
## z.diff.lag17  0.0036970  0.0150701   0.245 0.806217    
## z.diff.lag18  0.0213157  0.0150657   1.415 0.157181    
## z.diff.lag19 -0.0208312  0.0150734  -1.382 0.167045    
## z.diff.lag20  0.0231948  0.0150594   1.540 0.123580    
## z.diff.lag21 -0.0121453  0.0150699  -0.806 0.420326    
## z.diff.lag22  0.0108505  0.0150641   0.720 0.471386    
## z.diff.lag23 -0.0288360  0.0150596  -1.915 0.055584 .  
## z.diff.lag24  0.0154401  0.0150644   1.025 0.305447    
## z.diff.lag25 -0.0165692  0.0150846  -1.098 0.272082    
## z.diff.lag26 -0.0029072  0.0150901  -0.193 0.847240    
## z.diff.lag27 -0.0153191  0.0151127  -1.014 0.310799    
## z.diff.lag28  0.0197344  0.0151066   1.306 0.191502    
## z.diff.lag29  0.0215543  0.0150874   1.429 0.153181    
## z.diff.lag30 -0.0210689  0.0151144  -1.394 0.163399    
## z.diff.lag31 -0.0097965  0.0151022  -0.649 0.516578    
## z.diff.lag32 -0.0335534  0.0150713  -2.226 0.026043 *  
## z.diff.lag33 -0.0069324  0.0150691  -0.460 0.645513    
## z.diff.lag34  0.0455015  0.0150509   3.023 0.002516 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01639 on 4445 degrees of freedom
## Multiple R-squared:  0.0234, Adjusted R-squared:  0.01571 
## F-statistic: 3.043 on 35 and 4445 DF,  p-value: 5.157e-09
## 
## 
## Value of test-statistic is: -1.874 2.0146 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.43 -2.86 -2.57
## phi1  6.43  4.59  3.78


Model B,

\[\Delta {y_t} = \gamma {y_{t - 1}} + \mu + \sum\limits_{i = 1}^{p - 1} {{p_i}} \Delta {y_{t - i}} + {e_t}\]
In Model B we first look at the \(\tau_2\) statistic under the null, \(H_0:\) \(\gamma=0\); Fail to Reject. Next we look at \(\phi_1\) statistic under the null \(H_0:\) \(\gamma=\mu=0\) which really means, based on the previous result, that we are testing if \(\mu=0\); Fail to Reject, which confirms again we are dealing with a Pure Random Walk.

As a final verification we can look to Model A.

#Model A
u3 <- ur.df(log_INDEX_SSEC, type="none", lags=34, selectlags = "Fixed")
plot(u3)

summary(u3)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.093946 -0.007650  0.000333  0.008056  0.093838 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## z.lag.1       2.006e-05  3.221e-05   0.623 0.533399    
## z.diff.lag1   2.608e-02  1.498e-02   1.740 0.081866 .  
## z.diff.lag2  -3.073e-02  1.499e-02  -2.051 0.040357 *  
## z.diff.lag3   3.642e-02  1.499e-02   2.430 0.015144 *  
## z.diff.lag4   5.437e-02  1.500e-02   3.626 0.000292 ***
## z.diff.lag5   5.600e-03  1.500e-02   0.373 0.708982    
## z.diff.lag6  -5.157e-02  1.500e-02  -3.438 0.000591 ***
## z.diff.lag7   3.556e-02  1.501e-02   2.369 0.017893 *  
## z.diff.lag8  -7.327e-03  1.502e-02  -0.488 0.625619    
## z.diff.lag9  -1.127e-03  1.502e-02  -0.075 0.940182    
## z.diff.lag10 -2.946e-03  1.502e-02  -0.196 0.844500    
## z.diff.lag11  8.792e-03  1.502e-02   0.585 0.558306    
## z.diff.lag12  2.907e-02  1.502e-02   1.936 0.052955 .  
## z.diff.lag13  4.184e-02  1.503e-02   2.785 0.005381 ** 
## z.diff.lag14 -2.115e-02  1.506e-02  -1.405 0.160201    
## z.diff.lag15  4.855e-02  1.506e-02   3.224 0.001273 ** 
## z.diff.lag16  1.317e-03  1.507e-02   0.087 0.930368    
## z.diff.lag17  3.166e-03  1.507e-02   0.210 0.833607    
## z.diff.lag18  2.076e-02  1.507e-02   1.378 0.168254    
## z.diff.lag19 -2.139e-02  1.508e-02  -1.419 0.156091    
## z.diff.lag20  2.262e-02  1.506e-02   1.502 0.133276    
## z.diff.lag21 -1.275e-02  1.507e-02  -0.846 0.397459    
## z.diff.lag22  1.025e-02  1.507e-02   0.680 0.496339    
## z.diff.lag23 -2.949e-02  1.506e-02  -1.958 0.050260 .  
## z.diff.lag24  1.481e-02  1.507e-02   0.983 0.325680    
## z.diff.lag25 -1.723e-02  1.509e-02  -1.142 0.253392    
## z.diff.lag26 -3.545e-03  1.509e-02  -0.235 0.814292    
## z.diff.lag27 -1.596e-02  1.511e-02  -1.056 0.290990    
## z.diff.lag28  1.911e-02  1.511e-02   1.265 0.205892    
## z.diff.lag29  2.095e-02  1.509e-02   1.389 0.164980    
## z.diff.lag30 -2.171e-02  1.512e-02  -1.437 0.150892    
## z.diff.lag31 -1.046e-02  1.510e-02  -0.692 0.488768    
## z.diff.lag32 -3.426e-02  1.507e-02  -2.273 0.023048 *  
## z.diff.lag33 -7.579e-03  1.507e-02  -0.503 0.615060    
## z.diff.lag34  4.480e-02  1.505e-02   2.977 0.002928 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01639 on 4446 degrees of freedom
## Multiple R-squared:  0.02275,    Adjusted R-squared:  0.01506 
## F-statistic: 2.957 on 35 and 4446 DF,  p-value: 1.428e-08
## 
## 
## Value of test-statistic is: 0.6229 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62


Model A,

\[\Delta {y_t} = \gamma {y_{t - 1}} + \sum\limits_{i = 1}^{p - 1} {{p_i}} \Delta {y_{t - i}} + {e_t}\]
We are testing \(H_0: \gamma=0\). When we look at \(\tau_1\) we see that we Fail to Reject the null which confirms, in the strongest way, that we are dealing with a Pure Random Walk.

We will look again at Model C to determine if differencing the series once I(1) will suffice or if we need to difference twice I(2).

# Model C Differenced Data
u4 <- ur.df(diff_log_INDEX_SSEC, type="trend", lags=34, selectlags = "Fixed")
plot(u4)

summary(u4)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.094306 -0.007612  0.000278  0.007937  0.094472 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.823e-04  4.959e-04   0.569 0.569133    
## z.lag.1      -8.187e-01  7.801e-02 -10.495  < 2e-16 ***
## tt           -5.125e-08  1.893e-07  -0.271 0.786655    
## z.diff.lag1  -1.567e-01  7.701e-02  -2.036 0.041859 *  
## z.diff.lag2  -1.872e-01  7.586e-02  -2.467 0.013647 *  
## z.diff.lag3  -1.497e-01  7.474e-02  -2.003 0.045215 *  
## z.diff.lag4  -9.473e-02  7.370e-02  -1.285 0.198700    
## z.diff.lag5  -8.918e-02  7.265e-02  -1.228 0.219658    
## z.diff.lag6  -1.410e-01  7.163e-02  -1.968 0.049075 *  
## z.diff.lag7  -1.057e-01  7.057e-02  -1.498 0.134295    
## z.diff.lag8  -1.123e-01  6.941e-02  -1.618 0.105731    
## z.diff.lag9  -1.134e-01  6.831e-02  -1.661 0.096871 .  
## z.diff.lag10 -1.163e-01  6.718e-02  -1.731 0.083555 .  
## z.diff.lag11 -1.077e-01  6.610e-02  -1.629 0.103430    
## z.diff.lag12 -7.771e-02  6.494e-02  -1.197 0.231506    
## z.diff.lag13 -3.620e-02  6.383e-02  -0.567 0.570616    
## z.diff.lag14 -5.706e-02  6.263e-02  -0.911 0.362330    
## z.diff.lag15 -9.312e-03  6.144e-02  -0.152 0.879546    
## z.diff.lag16 -7.723e-03  6.017e-02  -0.128 0.897877    
## z.diff.lag17 -5.346e-03  5.892e-02  -0.091 0.927707    
## z.diff.lag18  1.579e-02  5.758e-02   0.274 0.783947    
## z.diff.lag19 -5.739e-03  5.622e-02  -0.102 0.918696    
## z.diff.lag20  1.589e-02  5.482e-02   0.290 0.772003    
## z.diff.lag21  3.552e-03  5.321e-02   0.067 0.946777    
## z.diff.lag22  1.252e-02  5.160e-02   0.243 0.808373    
## z.diff.lag23 -1.778e-02  4.980e-02  -0.357 0.721110    
## z.diff.lag24 -3.451e-03  4.778e-02  -0.072 0.942421    
## z.diff.lag25 -2.065e-02  4.559e-02  -0.453 0.650558    
## z.diff.lag26 -2.384e-02  4.333e-02  -0.550 0.582269    
## z.diff.lag27 -4.023e-02  4.094e-02  -0.983 0.325869    
## z.diff.lag28 -2.249e-02  3.844e-02  -0.585 0.558535    
## z.diff.lag29  1.257e-04  3.558e-02   0.004 0.997182    
## z.diff.lag30 -2.200e-02  3.280e-02  -0.671 0.502507    
## z.diff.lag31 -3.405e-02  2.970e-02  -1.147 0.251583    
## z.diff.lag32 -6.854e-02  2.585e-02  -2.651 0.008043 ** 
## z.diff.lag33 -7.528e-02  2.097e-02  -3.589 0.000335 ***
## z.diff.lag34 -3.071e-02  1.506e-02  -2.039 0.041480 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01639 on 4443 degrees of freedom
## Multiple R-squared:  0.5007, Adjusted R-squared:  0.4966 
## F-statistic: 123.8 on 36 and 4443 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -10.495 36.7179 55.0762 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2  6.09  4.68  4.03
## phi3  8.27  6.25  5.34


Looking at the results from the above test we can conclude, by viewing the \(\tau_3\) statistic that we Reject the idea that we need to difference the data more than once. In other words, I(1) differencing is sufficient for this time series.

Testing to Fail to Reject the null is somewhat inappropriate. Since we had a Difference Stationary time series it would be better to use a test where the alternative is testing for Difference Stationarity. This is where the KPSS test come into play, which we will view next. In addition to the KPSS test we could present our differenced data to the testing under the ADF test which would then make our alternative hypnosis testing for Difference Stationary time series, which we did in the final step above but for a different reason.

As a final exercise I will show this at the end of the KPSS testing.

# KPSS Test - H0-Trend Stationary (tseries)
kpss.test(log_INDEX_SSEC, null = "Trend")
## 
##  KPSS Test for Trend Stationarity
## 
## data:  log_INDEX_SSEC
## KPSS Trend = 1.0312, Truncation lag parameter = 15, p-value = 0.01
# KPSS Test - H0-Level Stationary (tseries)
kpss.test(log_INDEX_SSEC, null = "Level")
## 
##  KPSS Test for Level Stationarity
## 
## data:  log_INDEX_SSEC
## KPSS Level = 13.089, Truncation lag parameter = 15, p-value = 0.01


The p-values of the above KPSS tests is small which indicates we should reject the null that this is a Trend Stationary Series, further adding to the evidence that this time series has a unit root.

# KPSS Test - H0-Trend Stationary-mu (urca)
u.IPB_mu.kpss <- ur.kpss(log_INDEX_SSEC, type = "mu")
summary(u.IPB_mu.kpss)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: mu with 10 lags. 
## 
## Value of test-statistic is: 18.9966 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.347 0.463  0.574 0.739
# KPSS Test - H0-Trend Stationary-tau (urca)
u.IPB_tau.kpss <- ur.kpss(log_INDEX_SSEC, type = "tau")
summary(u.IPB_tau.kpss)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: tau with 10 lags. 
## 
## Value of test-statistic is: 1.4954 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.119 0.146  0.176 0.216


In the above KPSS test the critical values are well into the rejection region indicating this is not a trend stationary time series.

adf.test(diff_log_INDEX_SSEC)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  diff_log_INDEX_SSEC
## Dickey-Fuller = -14.605, Lag order = 16, p-value = 0.01
## alternative hypothesis: stationary
# Model C
u1.diff <- ur.df(diff_log_INDEX_SSEC, type="trend", lags=34, selectlags = "Fixed")
summary(u1.diff)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.094306 -0.007612  0.000278  0.007937  0.094472 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.823e-04  4.959e-04   0.569 0.569133    
## z.lag.1      -8.187e-01  7.801e-02 -10.495  < 2e-16 ***
## tt           -5.125e-08  1.893e-07  -0.271 0.786655    
## z.diff.lag1  -1.567e-01  7.701e-02  -2.036 0.041859 *  
## z.diff.lag2  -1.872e-01  7.586e-02  -2.467 0.013647 *  
## z.diff.lag3  -1.497e-01  7.474e-02  -2.003 0.045215 *  
## z.diff.lag4  -9.473e-02  7.370e-02  -1.285 0.198700    
## z.diff.lag5  -8.918e-02  7.265e-02  -1.228 0.219658    
## z.diff.lag6  -1.410e-01  7.163e-02  -1.968 0.049075 *  
## z.diff.lag7  -1.057e-01  7.057e-02  -1.498 0.134295    
## z.diff.lag8  -1.123e-01  6.941e-02  -1.618 0.105731    
## z.diff.lag9  -1.134e-01  6.831e-02  -1.661 0.096871 .  
## z.diff.lag10 -1.163e-01  6.718e-02  -1.731 0.083555 .  
## z.diff.lag11 -1.077e-01  6.610e-02  -1.629 0.103430    
## z.diff.lag12 -7.771e-02  6.494e-02  -1.197 0.231506    
## z.diff.lag13 -3.620e-02  6.383e-02  -0.567 0.570616    
## z.diff.lag14 -5.706e-02  6.263e-02  -0.911 0.362330    
## z.diff.lag15 -9.312e-03  6.144e-02  -0.152 0.879546    
## z.diff.lag16 -7.723e-03  6.017e-02  -0.128 0.897877    
## z.diff.lag17 -5.346e-03  5.892e-02  -0.091 0.927707    
## z.diff.lag18  1.579e-02  5.758e-02   0.274 0.783947    
## z.diff.lag19 -5.739e-03  5.622e-02  -0.102 0.918696    
## z.diff.lag20  1.589e-02  5.482e-02   0.290 0.772003    
## z.diff.lag21  3.552e-03  5.321e-02   0.067 0.946777    
## z.diff.lag22  1.252e-02  5.160e-02   0.243 0.808373    
## z.diff.lag23 -1.778e-02  4.980e-02  -0.357 0.721110    
## z.diff.lag24 -3.451e-03  4.778e-02  -0.072 0.942421    
## z.diff.lag25 -2.065e-02  4.559e-02  -0.453 0.650558    
## z.diff.lag26 -2.384e-02  4.333e-02  -0.550 0.582269    
## z.diff.lag27 -4.023e-02  4.094e-02  -0.983 0.325869    
## z.diff.lag28 -2.249e-02  3.844e-02  -0.585 0.558535    
## z.diff.lag29  1.257e-04  3.558e-02   0.004 0.997182    
## z.diff.lag30 -2.200e-02  3.280e-02  -0.671 0.502507    
## z.diff.lag31 -3.405e-02  2.970e-02  -1.147 0.251583    
## z.diff.lag32 -6.854e-02  2.585e-02  -2.651 0.008043 ** 
## z.diff.lag33 -7.528e-02  2.097e-02  -3.589 0.000335 ***
## z.diff.lag34 -3.071e-02  1.506e-02  -2.039 0.041480 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01639 on 4443 degrees of freedom
## Multiple R-squared:  0.5007, Adjusted R-squared:  0.4966 
## F-statistic: 123.8 on 36 and 4443 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -10.495 36.7179 55.0762 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2  6.09  4.68  4.03
## phi3  8.27  6.25  5.34
# KPSS Test - H0-Trend Stationary (tseries)
kpss.test(diff_log_INDEX_SSEC, null = "Trend")
## 
##  KPSS Test for Trend Stationarity
## 
## data:  diff_log_INDEX_SSEC
## KPSS Trend = 0.060991, Truncation lag parameter = 15, p-value =
## 0.1
# KPSS Test - H0-Level Stationary (tseries)
kpss.test(diff_log_INDEX_SSEC, null = "Level")
## 
##  KPSS Test for Level Stationarity
## 
## data:  diff_log_INDEX_SSEC
## KPSS Level = 0.066802, Truncation lag parameter = 15, p-value =
## 0.1
# KPSS Test - H0-Trend Stationary-mu (urca)
u1.IPB_mu.kpss.diff <- ur.kpss(diff_log_INDEX_SSEC, type = "mu")
summary(u1.IPB_mu.kpss.diff)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: mu with 10 lags. 
## 
## Value of test-statistic is: 0.0698 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.347 0.463  0.574 0.739
# KPSS Test - H0-Trend Stationary-tau (urca)
u1.IPB_tau.kpss.diff <- ur.kpss(diff_log_INDEX_SSEC, type = "tau")
summary(u1.IPB_tau.kpss.diff)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: tau with 10 lags. 
## 
## Value of test-statistic is: 0.0637 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.119 0.146  0.176 0.216


In the above ADF and KPSS tests where I passed the tests Differenced Data I received the results I expected. For the ADF tests the null was rejected and for the KPSS tests the null failed to be rejected.





Catagory C Time Series:
Yield on BAA Corporate Bonds, FED/RIMLPBAAR_N_M


str(RIMLPBAAR_N_M)
## 'zooreg' series from Jan 1919 to Jan 2016
##   Data: num [1:1165] 7.12 7.2 7.15 7.23 7.09 7.04 7.06 7.13 7.27 7.34 ...
##   Index: Class 'yearmon'  num [1:1165] 1919 1919 1919 1919 1919 ...
##   Frequency: 12






The ACF and PACF suggest nonstationarity and the presence of deterministic or stochastic trend.

I will follow the same procedure as above to analyze this time series data set.

According to Schwert model, a staring point for \(p_{max}\) = 22 lags.

\[{l_{12}} = {\mathop{\rm int}} \left\{ {12{{\left( {{T \over {100}}} \right)}^{{1 \over 4}}}} \right\}\]
The actual number of lags that seems to reduce all serial correlation in the residuals is 16 lags.

## 
##  Augmented Dickey-Fuller Test
## 
## data:  RIMLPBAAR_N_M
## Dickey-Fuller = -2.1761, Lag order = 10, p-value = 0.5038
## alternative hypothesis: stationary


According to this initial ADF Test we Fail to Reject the null that this is a Difference Stationary time series, indicating this time series may have a unit root.

# Model C
v1 <- ur.df(RIMLPBAAR_N_M, type="trend", lags=16, selectlags = "Fixed")
plot(v1)

summary(v1)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.32979 -0.06582 -0.00251  0.06720  1.63585 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.165e-02  1.738e-02   1.246 0.212976    
## z.lag.1      -4.550e-03  2.330e-03  -1.952 0.051134 .  
## tt            1.427e-05  1.966e-05   0.726 0.468170    
## z.diff.lag1   3.246e-01  2.964e-02  10.953  < 2e-16 ***
## z.diff.lag2  -5.647e-02  3.098e-02  -1.823 0.068629 .  
## z.diff.lag3  -1.067e-01  3.103e-02  -3.440 0.000604 ***
## z.diff.lag4   3.891e-02  3.107e-02   1.252 0.210692    
## z.diff.lag5   4.003e-02  3.109e-02   1.287 0.198196    
## z.diff.lag6   3.688e-02  3.110e-02   1.186 0.235961    
## z.diff.lag7   8.317e-02  3.112e-02   2.673 0.007629 ** 
## z.diff.lag8  -3.566e-02  3.109e-02  -1.147 0.251625    
## z.diff.lag9   1.028e-01  3.114e-02   3.301 0.000995 ***
## z.diff.lag10  1.658e-02  3.121e-02   0.531 0.595344    
## z.diff.lag11  1.838e-02  3.121e-02   0.589 0.556078    
## z.diff.lag12  2.230e-02  3.120e-02   0.715 0.474958    
## z.diff.lag13 -8.150e-02  3.121e-02  -2.611 0.009140 ** 
## z.diff.lag14 -1.038e-02  3.111e-02  -0.334 0.738594    
## z.diff.lag15 -1.099e-01  3.106e-02  -3.539 0.000418 ***
## z.diff.lag16  7.501e-02  2.974e-02   2.522 0.011805 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2057 on 1129 degrees of freedom
## Multiple R-squared:  0.1619, Adjusted R-squared:  0.1486 
## F-statistic: 12.12 on 18 and 1129 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -1.9524 1.3012 1.9063 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2  6.09  4.68  4.03
## phi3  8.27  6.25  5.34


We start by testing against Model C, \[\Delta {y_t} = \gamma {y_{t - 1}} + \mu + \beta t + \sum\limits_{i = 1}^{p - 1} {{p_i}} \Delta {y_{t - i}} + {e_t}\] where we look at the \(\phi_3\) statistic to test \(H_0:\) \(\gamma=\beta=0\)

According to the critical region we Fail to Reject the null which implies that this time series data set contains a unit root. This is further confirmed by looking at \(\tau_3\) statistic for the lagged endogenous variable in levels to see that we Fail to Reject the null that \(H_0:\) \(\gamma=0\). Again a unit root can not be rejected.

We next look at the \(\phi_2\) statistic to determine if this time series data is a pure random walk or a random walk with drift. The \(H_0: \gamma=\mu=\beta=0\) but since we have already determined that \(\gamma=\beta=0\) in previous hypothesis test we are really testing for \(\mu=0\). We find that we Fail to Reject this hypnosis which indicates we are dealing with a Pure Random Walk.

This can be further confirmed by now testing several hypothesis on Model B.

# Model B
v2 <- ur.df(RIMLPBAAR_N_M, type="drift", lags=16, selectlags = "Fixed")
plot(v2)

summary(v2)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.33607 -0.06757 -0.00272  0.06716  1.62972 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.025798   0.016406   1.572 0.116123    
## z.lag.1      -0.003940   0.002173  -1.813 0.070085 .  
## z.diff.lag1   0.324378   0.029629  10.948  < 2e-16 ***
## z.diff.lag2  -0.056770   0.030972  -1.833 0.067073 .  
## z.diff.lag3  -0.107001   0.031018  -3.450 0.000582 ***
## z.diff.lag4   0.038714   0.031064   1.246 0.212919    
## z.diff.lag5   0.039791   0.031086   1.280 0.200795    
## z.diff.lag6   0.036570   0.031092   1.176 0.239771    
## z.diff.lag7   0.082807   0.031105   2.662 0.007875 ** 
## z.diff.lag8  -0.036141   0.031075  -1.163 0.245069    
## z.diff.lag9   0.102232   0.031121   3.285 0.001051 ** 
## z.diff.lag10  0.015984   0.031194   0.512 0.608474    
## z.diff.lag11  0.017739   0.031187   0.569 0.569604    
## z.diff.lag12  0.021592   0.031181   0.692 0.488769    
## z.diff.lag13 -0.082136   0.031190  -2.633 0.008568 ** 
## z.diff.lag14 -0.010931   0.031093  -0.352 0.725240    
## z.diff.lag15 -0.110437   0.031048  -3.557 0.000391 ***
## z.diff.lag16  0.074361   0.029724   2.502 0.012499 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2057 on 1130 degrees of freedom
## Multiple R-squared:  0.1615, Adjusted R-squared:  0.1489 
## F-statistic: 12.81 on 17 and 1130 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -1.8131 1.6892 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.43 -2.86 -2.57
## phi1  6.43  4.59  3.78


Model B,

\[\Delta {y_t} = \gamma {y_{t - 1}} + \mu + \sum\limits_{i = 1}^{p - 1} {{p_i}} \Delta {y_{t - i}} + {e_t}\]
In Model B we first look at the \(\tau_2\) statistic under the null, \(H_0:\) \(\gamma=0\); Fail to Reject. Next we look at \(\phi_1\) statistic under the null \(H_0:\) \(\gamma=\mu=0\) which really means, based on the previous result, that we are testing if \(\mu=0\); Fail to Reject, which confirms again we are dealing with a Pure Random Walk.

As a final verification we can look to Model A.

# Model A
v3 <- ur.df(RIMLPBAAR_N_M, type="none", lags=16, selectlags = "Fixed")
plot(v3)

summary(v3)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.33654 -0.06280  0.00337  0.07024  1.63242 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## z.lag.1      -0.0007658  0.0008051  -0.951 0.341749    
## z.diff.lag1   0.3232090  0.0296385  10.905  < 2e-16 ***
## z.diff.lag2  -0.0583450  0.0309760  -1.884 0.059882 .  
## z.diff.lag3  -0.1084357  0.0310250  -3.495 0.000492 ***
## z.diff.lag4   0.0377501  0.0310779   1.215 0.224738    
## z.diff.lag5   0.0386637  0.0310978   1.243 0.214017    
## z.diff.lag6   0.0353255  0.0311026   1.136 0.256293    
## z.diff.lag7   0.0814463  0.0311136   2.618 0.008970 ** 
## z.diff.lag8  -0.0379530  0.0310738  -1.221 0.222195    
## z.diff.lag9   0.1005180  0.0311224   3.230 0.001275 ** 
## z.diff.lag10  0.0138855  0.0311857   0.445 0.656224    
## z.diff.lag11  0.0155170  0.0311756   0.498 0.618772    
## z.diff.lag12  0.0191935  0.0311637   0.616 0.538089    
## z.diff.lag13 -0.0846159  0.0311704  -2.715 0.006736 ** 
## z.diff.lag14 -0.0129303  0.0310868  -0.416 0.677532    
## z.diff.lag15 -0.1122935  0.0310457  -3.617 0.000311 ***
## z.diff.lag16  0.0719612  0.0297037   2.423 0.015565 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2058 on 1131 degrees of freedom
## Multiple R-squared:  0.1598, Adjusted R-squared:  0.1472 
## F-statistic: 12.65 on 17 and 1131 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -0.9511 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62


Model A,

\[\Delta {y_t} = \gamma {y_{t - 1}} + \sum\limits_{i = 1}^{p - 1} {{p_i}} \Delta {y_{t - i}} + {e_t}\]
We are testing \(H_0: \gamma=0\). When we look at \(\tau_1\) we see that we Fail to Reject the null which confirms, in the strongest way, that we are dealing with a Pure Random Walk.

We will look again at Model C to determine if differencing the series once I(1) will suffice or if we need to difference twice I(2).

# Model C Differenced Data
v4 <- ur.df(diff_RIMLPBAAR_N_M, type="trend", lags=16, selectlags = "Fixed")
plot(v4)

summary(v4)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.34289 -0.06551  0.00034  0.06450  1.63012 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -1.622e-03  1.244e-02  -0.130  0.89626    
## z.lag.1      -6.929e-01  8.539e-02  -8.115 1.26e-15 ***
## tt           -2.217e-07  1.839e-05  -0.012  0.99038    
## z.diff.lag1   1.775e-02  8.348e-02   0.213  0.83170    
## z.diff.lag2  -4.266e-02  8.044e-02  -0.530  0.59596    
## z.diff.lag3  -1.517e-01  7.819e-02  -1.940  0.05261 .  
## z.diff.lag4  -1.151e-01  7.610e-02  -1.512  0.13074    
## z.diff.lag5  -7.653e-02  7.449e-02  -1.027  0.30447    
## z.diff.lag6  -4.061e-02  7.266e-02  -0.559  0.57633    
## z.diff.lag7   4.114e-02  7.066e-02   0.582  0.56051    
## z.diff.lag8   4.556e-03  6.848e-02   0.067  0.94697    
## z.diff.lag9   1.044e-01  6.540e-02   1.596  0.11082    
## z.diff.lag10  1.194e-01  6.256e-02   1.909  0.05655 .  
## z.diff.lag11  1.350e-01  5.874e-02   2.299  0.02170 *  
## z.diff.lag12  1.545e-01  5.432e-02   2.845  0.00453 ** 
## z.diff.lag13  6.967e-02  4.893e-02   1.424  0.15479    
## z.diff.lag14  5.467e-02  4.200e-02   1.302  0.19330    
## z.diff.lag15 -5.928e-02  3.592e-02  -1.651  0.09911 .  
## z.diff.lag16  1.842e-02  2.983e-02   0.618  0.53695    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2061 on 1128 degrees of freedom
## Multiple R-squared:  0.391,  Adjusted R-squared:  0.3813 
## F-statistic: 40.24 on 18 and 1128 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -8.1148 21.9727 32.9585 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2  6.09  4.68  4.03
## phi3  8.27  6.25  5.34


Looking at the results from the above test we can conclude, by viewing the \(\tau_3\) statistic that we Reject the idea that we need to difference the data more than once. In other words, I(1) differencing is sufficient for this time series.

Testing to Fail to Reject the null is somewhat inappropriate. Since we had a Difference Stationary time series it would be better to use a test where the alternative is testing for Difference Stationarity. This is where the KPSS test come into play, which we will view next. In addition to the KPSS test we could present our differenced data to the testing under the ADF test which would then make our alternative hypnosis testing for Difference Stationary time series, which we did in the final step above but for a different reason.

As a final exercise I will show this at the end of the KPSS testing.

# KPSS Test - H0-Trend Stationary (tseries)
kpss.test(RIMLPBAAR_N_M, null = "Trend")
## 
##  KPSS Test for Trend Stationarity
## 
## data:  RIMLPBAAR_N_M
## KPSS Trend = 1.47, Truncation lag parameter = 7, p-value = 0.01
# KPSS Test - H0-Level Stationary (tseries)
kpss.test(RIMLPBAAR_N_M, null = "Level")
## 
##  KPSS Test for Level Stationarity
## 
## data:  RIMLPBAAR_N_M
## KPSS Level = 3.6706, Truncation lag parameter = 7, p-value = 0.01


The p-values of the above KPSS tests is small which indicates we should reject the null that this is a Trend Stationary Series, further adding to the evidence that this time series has a unit root.

# KPSS Test - H0-Trend Stationary-mu (urca)
v.IPB_mu.kpss <- ur.kpss(RIMLPBAAR_N_M, type = "mu")
summary(v.IPB_mu.kpss)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: mu with 7 lags. 
## 
## Value of test-statistic is: 3.6706 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.347 0.463  0.574 0.739
# KPSS Test - H0-Trend Stationary-tau (urca)
v.IPB_tau.kpss <- ur.kpss(RIMLPBAAR_N_M, type = "tau")
summary(v.IPB_tau.kpss)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: tau with 7 lags. 
## 
## Value of test-statistic is: 1.47 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.119 0.146  0.176 0.216


In the above KPSS test the critical values are well into the rejection region indicating this is not a trend stationary time series.

adf.test(diff_log_INDEX_SSEC)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  diff_log_INDEX_SSEC
## Dickey-Fuller = -14.605, Lag order = 16, p-value = 0.01
## alternative hypothesis: stationary
# Model C
v1.diff <- ur.df(diff_RIMLPBAAR_N_M, type="trend", lags=16, selectlags = "Fixed")
summary(v1.diff)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.34289 -0.06551  0.00034  0.06450  1.63012 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -1.622e-03  1.244e-02  -0.130  0.89626    
## z.lag.1      -6.929e-01  8.539e-02  -8.115 1.26e-15 ***
## tt           -2.217e-07  1.839e-05  -0.012  0.99038    
## z.diff.lag1   1.775e-02  8.348e-02   0.213  0.83170    
## z.diff.lag2  -4.266e-02  8.044e-02  -0.530  0.59596    
## z.diff.lag3  -1.517e-01  7.819e-02  -1.940  0.05261 .  
## z.diff.lag4  -1.151e-01  7.610e-02  -1.512  0.13074    
## z.diff.lag5  -7.653e-02  7.449e-02  -1.027  0.30447    
## z.diff.lag6  -4.061e-02  7.266e-02  -0.559  0.57633    
## z.diff.lag7   4.114e-02  7.066e-02   0.582  0.56051    
## z.diff.lag8   4.556e-03  6.848e-02   0.067  0.94697    
## z.diff.lag9   1.044e-01  6.540e-02   1.596  0.11082    
## z.diff.lag10  1.194e-01  6.256e-02   1.909  0.05655 .  
## z.diff.lag11  1.350e-01  5.874e-02   2.299  0.02170 *  
## z.diff.lag12  1.545e-01  5.432e-02   2.845  0.00453 ** 
## z.diff.lag13  6.967e-02  4.893e-02   1.424  0.15479    
## z.diff.lag14  5.467e-02  4.200e-02   1.302  0.19330    
## z.diff.lag15 -5.928e-02  3.592e-02  -1.651  0.09911 .  
## z.diff.lag16  1.842e-02  2.983e-02   0.618  0.53695    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2061 on 1128 degrees of freedom
## Multiple R-squared:  0.391,  Adjusted R-squared:  0.3813 
## F-statistic: 40.24 on 18 and 1128 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -8.1148 21.9727 32.9585 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2  6.09  4.68  4.03
## phi3  8.27  6.25  5.34
# KPSS Test - H0-Trend Stationary (tseries)
kpss.test(diff_RIMLPBAAR_N_M, null = "Trend")
## 
##  KPSS Test for Trend Stationarity
## 
## data:  diff_RIMLPBAAR_N_M
## KPSS Trend = 0.10662, Truncation lag parameter = 7, p-value = 0.1
# KPSS Test - H0-Level Stationary (tseries)
kpss.test(diff_RIMLPBAAR_N_M, null = "Level")
## 
##  KPSS Test for Level Stationarity
## 
## data:  diff_RIMLPBAAR_N_M
## KPSS Level = 0.11397, Truncation lag parameter = 7, p-value = 0.1
# KPSS Test - H0-Trend Stationary-mu (urca)
v1.IPB_mu.kpss.diff <- ur.kpss(diff_RIMLPBAAR_N_M, type = "mu")
summary(v1.IPB_mu.kpss.diff)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: mu with 7 lags. 
## 
## Value of test-statistic is: 0.114 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.347 0.463  0.574 0.739
# KPSS Test - H0-Trend Stationary-tau (urca)
v1.IPB_tau.kpss.diff <- ur.kpss(diff_RIMLPBAAR_N_M, type = "tau")
summary(v1.IPB_tau.kpss.diff)
## 
## ####################### 
## # KPSS Unit Root Test # 
## ####################### 
## 
## Test is of type: tau with 7 lags. 
## 
## Value of test-statistic is: 0.1066 
## 
## Critical value for a significance level of: 
##                 10pct  5pct 2.5pct  1pct
## critical values 0.119 0.146  0.176 0.216


In the above ADF and KPSS tests where I passed the tests Differenced Data I received the results I expected. For the ADF tests the null was rejected and for the KPSS tests the null failed to be rejected.