Modeling non-stationary time series

Universidad Privada Boliviana / Universidad del Pacífico (Lima, Perú)

Author

Prof. J. Dávalos (Ph.D.)

Vector Autoregressions


Introduction

  • ARMA models are useful to forecast one time series at a time
  • But most economic problems imply assessing the relationship between many variables of interest e.g. think about all theoretical macro models.
  • One may safely assume that there exist some linear and unknown model that relates our contemporaneous variables of interest.

  • Consider the Cobweb model. Supply and demand at today’s price may also depend on past information \(\tau<t\):

    • \(S_t = f(P_t^e) ; D_t=f(P_t)\)
    • \(P^e_t = f(\{P_{\tau} , S_{\tau} , D_{\tau}\}) ; P_t = f(P^e_t)\)
  • Where \(P_t^e\) is suppliers’ expected price at time t. The past information \(\tau\) is exogenous to today (\(t\)), thus one can solve the system and identify a reduced form where every endogenous variable depends on past information:

    • \(S_t = g(\{P_{\tau}, S_{\tau}, D_{\tau}\}) ; D_t=g( \{P_{\tau} , S_{\tau} , D_{\tau}\})\)
    • \(P = f(\{P_{\tau} , S_{\tau} , D_{\tau}\})\)

  • This reduced form is a ADL model i.e. endogenous variables depend on each others’ past and own information.

  • This made the success of VAR representations, by analogy to ARMA ones, the dynamic relationships are fundamentally stochastic. Economic theory only guides the specification without imposing a hard structure (Remember the Lucas critique).


  • Visual representation of an unstable equilibrium…

VAR

  • The n-endogenous variables within \(\bf Y_t = [y_{1t}, y_{2t},....,y_{nt}]\), must be stationary I(0) in order to obtain well behaved I(0) + WN residuals.

    • \(\bf Y_t = v + \sum_{j=1}^p A_j Y_{t-j} + \bf \varepsilon_j\)
      • where \(\bf A\) is coefficients matrix.
  • The choice of lags such that the system exhibits well behaved residuals is performed by analyzing information criteria (Akaike, Schartz Bayesian, Hannan-Quinn). The formal test is a likelihood ratio test statistics that compares j lag Likelihood with its j-1 lag.

  • \(LR(j) = 2(LL(j) - LL(j-1))\)

  • The null is that the j-th lags are not statistically significant.

  • In stata the varsoc command provides this assesment.

VARX

  • Depeding on the problem at hand, one can include a vector of m-exogenous I(0) variables \(\bf X_t = [x_{1t}, x_{2t},...,x_{mt}]\):
    • \(\bf Y_t = v + \sum_{j=1}^p A_j Y_{t-j} + \sum_{j=1}^s B_j X_{t-j} + \bf \varepsilon_j \quad (1)\)

VAR, VARMA, VARMAX and VARIMAX ?

  • There many denominations to slight variants to the standard VAR model
  • SVAR: structural VAR. Structure comes from the residuals’ covariance behavior.
  • VARMA : includes moving average terms.
  • VARMAX: includes exogeneous variables and moving averages

  • VARIMAX: it is the multivariate analog of an arima i.e. it is performed over the d-th difference of I(d) variables. A standard model that employs the stationary transformations of non stationary variables
  • Each one has very narrow an specific applications in the literature, so here we will focus on the fundamental VAR model.

  • Since most economic application seek to understand what are the consequences of shocks in either exogenous variables or endogenous ones, we can not rely on equation (1).
  • Eq. (1) does not tell us how a shock on a given right hand side variable dissipates through the future \(Y_{t}\) through direct and indirect effects. Eq. (1) only accounts for direct effects on the \(\bf B\) and \(\bf A\) matrix.

Infinite MA representation

  • AR and VAR share a common characteristic, both have infinite MA representations. Take our last VARX model. Iterative substitutions of \(\bf Y_t\) imply:

\(\bf Y_t = a + \sum_{j=1}^s \tilde B_j X_{t-j} + \sum_{j=0}^{\infty} \bf \phi_j \varepsilon_j\)

  • This is the VMA, vector moving average representation of VAR. Now \(\tilde B\) (transfer function) accounts for the indirect + direct effects of shocks over \(X\). Similarly, \(\phi\) accounts for the direct an indirect effects of past shock on the endogenous variables (IRF).

Impulse response functions (IRF)

  • Impulse response function provide the estimated trajectories/responses that result from shocks on a given variable of the system i.e. dynamic multiplier effects.

  • The simpler IRF are given by matrix \(\bf \phi\)


Orthogonalized impulse response functions (OIRF)

  • An exogenous shock is rarely isolated. Example: A natural disaster that hits infrastructure, would also affect consumption and investment decisions (among others).

  • Even an exogenous policy instrument such as a tariff rate, subsidy, enhanced investments, etc. that is supposed to primarily affect a given variable, may also have inmediate simultaneous reactions on other variables.

  • Shocks should be applied as a combo i.e. the whole vector of residuals in the VMA representation should shocked based on the correlation between the main residual that gets the impulse and the remaining ones.


VAR estimation and diagnostics

* This is US macro data from 1959 to 2010
use http://fmwww.bc.edu/cfb/stata/DelivS4/usmacro1.dta, clear
gen date = tq(1959q1) +_n-1
format %tq date
tsset date

des
Time variable: date, 1959q1 to 2010q3
        Delta: 1 quarter


Contains data from http://fmwww.bc.edu/cfb/stata/DelivS4/usmacro1.dta
 Observations:           207                  
    Variables:            57                  25 Jan 2011 09:13
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ccode           int     %8.0g                 
year            int     %8.0g                 
qtr             byte    %8.0g                 
cpi             double  %10.0g                CPI
dcpi            double  %10.0g                CPI % CHANGE
oilprice        double  %10.0g                PETROLEUM:AVERAGE CRUDE PRICE
dgdpdef         double  %10.0g                GDP DEFLATOR % CHANGE
mbase           double  %10.0g                MONETARY BASE, SEASONALLY ADJUSTED
domcredit       double  %10.0g                DOMESTIC CREDIT
money           double  %10.0g                MONEY, SEASONALLY ADJUSTED
M1              double  %10.0g                M1 SEASONALLY ADJUSTED
M2              double  %10.0g                M2 SEASONALLY ADJUSTED
ffrate          double  %10.0g                FEDERAL FUNDS RATE
cprate          double  %10.0g                COMMERCIAL PAPER- 3 MONTH
tb3rate         double  %10.0g                T-BILL RATE-3 MNTH CONS. MAT.
libor3mo        double  %10.0g                3-MONTH US DEP. LONDON OFFER
primerate       double  %10.0g                BANK PRIME LOAN RATE
tr10yr          double  %10.0g                GOVT BOND YIELD: 10 YEAR
tr3yr           double  %10.0g                GOVT BOND YIELD: 3 YEAR
stockprice      double  %10.0g                SHARE PRICES
NASDAQindex     double  %10.0g                NASDAQ COMPOSITE
S_Pindex        double  %10.0g                S&P INDUSTRIALS
wage            double  %10.0g                WAGES: HOURLY EARNINGS, MFG
REER_RULC       double  %10.0g                REER BASED ON RULC
ip              double  %10.0g                INDUSTRIAL PRODUCTION SA
unemp           double  %10.0g                UNEMPLOYMENT RATE
exports         double  %10.0g                EXPORTS OF GOODS AND SERVICES SA
govt            double  %10.0g                GOVERNMENT CONSUMPTION EXPEND. SA
grossinv        double  %10.0g                GROSS FIXED CAPITAL FORMATION SA
dinventories    double  %10.0g                CHANGES IN INVENTORIES SA
consump         double  %10.0g                HOUSEH.CONS.EXPEND.,INCL.NPISHS SA
imports         double  %10.0g                IMPORTS OF GOODS AND SERVICES SA
gdp             double  %10.0g                GROSS DOMESTIC PRODUCT SA
gdpdefl         double  %10.0g                GDP DEFLATOR (2005=100)
yq              float   %tq                   
rexports        float   %9.0g                 REAL EXPORTS OF GOODS AND SERVICES
rgovt           float   %9.0g                 REAL GOVERNMENT CONSUMPTION EXPEND.
rgrossinv       float   %9.0g                 REAL GROSS FIXED CAPITAL FORMATION
rdinventories   float   %9.0g                 REAL CHANGES IN INVENTORIES
rconsump        float   %9.0g                 REAL HOUSEH.CONS.EXPEND.,INCL.NPISHS
rimports        float   %9.0g                 REAL IMPORTS OF GOODS AND SERVICES
rgdp            float   %9.0g                 REAL GROSS DOMESTIC PRODUCT
rM1             float   %9.0g                 REAL M1
rM2             float   %9.0g                 REAL M2
rmbase          float   %9.0g                 REAL MONETARY BASE
rwage           float   %9.0g                 REAL WAGES: HOURLY EARNINGS, MFG
lrexports       float   %9.0g                 LOG REAL EXPORTS OF GOODS AND SERVICES
lrgovt          float   %9.0g                 LOG REAL GOVERNMENT CONSUMPTION EXPEND.
lrgrossinv      float   %9.0g                 LOG REAL GROSS FIXED CAPITAL FORMATION
lrconsump       float   %9.0g                 LOG REAL HOUSEH.CONS.EXPEND.,INCL.NPISHS
lrimports       float   %9.0g                 LOG REAL IMPORTS OF GOODS AND SERVICES
lrgdp           float   %9.0g                 LOG REAL GROSS DOMESTIC PRODUCT
lrmbase         float   %9.0g                 LOG REAL MONETARY BASE
lrM1            float   %9.0g                 LOG REAL M1
lrM2            float   %9.0g                 LOG REAL M2
lrwage          float   %9.0g                 LOG REAL WAGES: HOURLY EARNINGS, MFG
date            float   %tq                   
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sorted by: date
     Note: Dataset has changed since last saved.

  • We seek to estimate a VAR between macroeconomic variables well-known to be linked by structural relationships. GDP, Gross Investment and Consumption. These are in log scale and I(1), so we will specify the VAR with their first difference which is I(0). You may try the ADF test to prove it.

  • Checking the suggested number of lags from the LR test. Since this is quarterly data, we start by 2 years of data (8 lags)

varsoc D.lrgrossinv D.lrconsump D.lrgdp ,maxlag(8)
Lag-order selection criteria

   Sample: 1961q2 thru 2010q3                              Number of obs = 198
  +---------------------------------------------------------------------------+
  | Lag |    LL      LR      df    p     FPE       AIC      HQIC      SBIC    |
  |-----+---------------------------------------------------------------------|
  |   0 |  1989.08                     3.9e-13  -20.0614  -20.0412  -20.0116  |
  |   1 |  2034.34   90.53    9  0.000 2.7e-13* -20.4277*  -20.347* -20.2284* |
  |   2 |  2040.87  13.058    9  0.160 2.8e-13  -20.4027  -20.2616   -20.054  |
  |   3 |  2048.17  14.607    9  0.102 2.8e-13  -20.3856  -20.1839  -19.8874  |
  |   4 |  2054.96  13.568    9  0.139 2.9e-13  -20.3632  -20.1011  -19.7155  |
  |   5 |  2064.92  19.916    9  0.018 2.9e-13  -20.3729  -20.0502  -19.5757  |
  |   6 |  2077.41   24.99*   9  0.003 2.8e-13  -20.4082   -20.025  -19.4616  |
  |   7 |  2079.69  4.5652    9  0.870 3.0e-13  -20.3403  -19.8967  -19.2443  |
  |   8 |  2087.38  15.369    9  0.081 3.0e-13  -20.3271  -19.8229  -19.0815  |
  +---------------------------------------------------------------------------+
   * optimal lag
   Endogenous: D.lrgrossinv D.lrconsump D.lrgdp
    Exogenous: _cons

8 we find 6 lags suggested lags


  • Let’s estimate a VAR until 2005 using the variation of the monetary base (log) as exogenous variable. Remember that this is a policy instrument, thus it can be considered exogenous by definition:

var D.lrgrossinv D.lrconsump D.lrgdp  if tin(,2005q4) , ///
 exog(D.lrmbase) lags(1/6)
Vector autoregression

Sample: 1960q4 thru 2005q4                      Number of obs     =        181
Log likelihood =   1910.063                     AIC               =  -20.44269
FPE            =   2.66e-13                     HQIC              =  -20.01283
Det(Sigma_ml)  =   1.37e-13                     SBIC              =  -19.38241

Equation           Parms      RMSE     R-sq      chi2     P>chi2
----------------------------------------------------------------
D_lrgrossinv         20     .016645   0.3242   86.82281   0.0000
D_lrconsump          20     .006515   0.1782   39.24667   0.0041
D_lrgdp              20     .007401   0.3270   87.95832   0.0000
----------------------------------------------------------------

------------------------------------------------------------------------------
             | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
D_lrgrossinv |
  lrgrossinv |
         LD. |   .2059855   .0938701     2.19   0.028     .0220034    .3899676
        L2D. |   .0854597   .0978285     0.87   0.382    -.1062805       .2772
        L3D. |  -.2004654   .0991175    -2.02   0.043    -.3947322   -.0061986
        L4D. |   .1530587   .0992366     1.54   0.123    -.0414414    .3475589
        L5D. |   .2392248   .0991176     2.41   0.016     .0449577    .4334918
        L6D. |   .1278134    .099423     1.29   0.199    -.0670521    .3226789
             |
   lrconsump |
         LD. |   .4648946    .261369     1.78   0.075    -.0473793    .9771684
        L2D. |    .025467   .2692574     0.09   0.925    -.5022678    .5532017
        L3D. |    .301016   .2626307     1.15   0.252    -.2137308    .8157627
        L4D. |    .264919   .2628097     1.01   0.313    -.2501786    .7800166
        L5D. |   .0328857   .2601852     0.13   0.899    -.4770679    .5428392
        L6D. |   .3666337   .2467208     1.49   0.137    -.1169302    .8501976
             |
       lrgdp |
         LD. |   .1380695   .2536932     0.54   0.586      -.35916     .635299
        L2D. |   .1415874   .2581146     0.55   0.583     -.364308    .6474827
        L3D. |   .0537493    .251337     0.21   0.831    -.4388622    .5463608
        L4D. |  -.3015159   .2439237    -1.24   0.216    -.7795976    .1765658
        L5D. |  -.4731841   .2413855    -1.96   0.050    -.9462909   -.0000772
        L6D. |  -.8701076    .227164    -3.83   0.000    -1.315341   -.4248743
             |
     lrmbase |
         D1. |  -.0219405   .1154734    -0.19   0.849    -.2482643    .2043832
             |
       _cons |   .0016901   .0037409     0.45   0.651     -.005642    .0090222
-------------+----------------------------------------------------------------
D_lrconsump  |
  lrgrossinv |
         LD. |   .0161461   .0367439     0.44   0.660    -.0558706    .0881628
        L2D. |  -.0388352   .0382933    -1.01   0.311    -.1138888    .0362183
        L3D. |  -.0462165   .0387979    -1.19   0.234     -.122259     .029826
        L4D. |   .0776756   .0388445     2.00   0.046     .0015418    .1538094
        L5D. |   .0578088    .038798     1.49   0.136    -.0182337    .1338514
        L6D. |   -.024781   .0389175    -0.64   0.524    -.1010579    .0514958
             |
   lrconsump |
         LD. |  -.0586304   .1023085    -0.57   0.567    -.2591514    .1418907
        L2D. |   .1206449   .1053963     1.14   0.252    -.0859281    .3272179
        L3D. |   .1947558   .1028024     1.89   0.058    -.0067332    .3962448
        L4D. |   .0262602   .1028725     0.26   0.799    -.1753662    .2278866
        L5D. |  -.0883115   .1018451    -0.87   0.386    -.2879243    .1113013
        L6D. |   .0501448   .0965748     0.52   0.604    -.1391382    .2394278
             |
       lrgdp |
         LD. |   .1679689    .099304     1.69   0.091    -.0266633    .3626011
        L2D. |   .1299104   .1010347     1.29   0.199    -.0681139    .3279347
        L3D. |  -.0953583   .0983817    -0.97   0.332    -.2881829    .0974662
        L4D. |  -.1511452   .0954799    -1.58   0.113    -.3382824    .0359919
        L5D. |  -.0240841   .0944863    -0.25   0.799    -.2092739    .1611057
        L6D. |  -.0283411   .0889196    -0.32   0.750    -.2026203    .1459381
             |
     lrmbase |
         D1. |   .1062364   .0452001     2.35   0.019     .0176457    .1948271
             |
       _cons |   .0056542   .0014643     3.86   0.000     .0027842    .0085242
-------------+----------------------------------------------------------------
D_lrgdp      |
  lrgrossinv |
         LD. |   .1516416   .0417416     3.63   0.000     .0698296    .2334535
        L2D. |   .0479411   .0435017     1.10   0.270    -.0373207    .1332029
        L3D. |   -.113988   .0440749    -2.59   0.010    -.2003733   -.0276027
        L4D. |   .0500452   .0441279     1.13   0.257    -.0364439    .1365343
        L5D. |  -.0207829    .044075    -0.47   0.637    -.1071682    .0656025
        L6D. |   .0328051   .0442108     0.74   0.458    -.0538465    .1194566
             |
   lrconsump |
         LD. |   .3223798   .1162239     2.77   0.006     .0945852    .5501744
        L2D. |   .1307568   .1197316     1.09   0.275    -.1039129    .3654264
        L3D. |   .1501446   .1167849     1.29   0.199    -.0787497    .3790388
        L4D. |     .20221   .1168645     1.73   0.084    -.0268403    .4312602
        L5D. |   .0626974   .1156974     0.54   0.588    -.1640654    .2894602
        L6D. |   .0902616   .1097102     0.82   0.411    -.1247665    .3052896
             |
       lrgdp |
         LD. |  -.1700045   .1128106    -1.51   0.132    -.3911093    .0511003
        L2D. |  -.0377538   .1147767    -0.33   0.742     -.262712    .1872045
        L3D. |  -.0557085   .1117629    -0.50   0.618    -.2747597    .1633428
        L4D. |  -.1048877   .1084664    -0.97   0.334     -.317478    .1077026
        L5D. |  -.1435489   .1073377    -1.34   0.181     -.353927    .0668292
        L6D. |   -.134725   .1010138    -1.33   0.182    -.3327085    .0632584
             |
     lrmbase |
         D1. |   .0820766    .051348     1.60   0.110    -.0185636    .1827167
             |
       _cons |   .0033719   .0016635     2.03   0.043     .0001115    .0066322
------------------------------------------------------------------------------

  • Let’s analyze the stability of the VAR, it should be stationary:
varstable
   Eigenvalue stability condition
  +----------------------------------------+
  |        Eigenvalue        |   Modulus   |
  |--------------------------+-------------|
  |   .2503241 +  .8084059i  |   .846276   |
  |   .2503241 -  .8084059i  |   .846276   |
  |  -.8107876 +  .2107872i  |    .83774   |
  |  -.8107876 -  .2107872i  |    .83774   |
  |   .8262012               |   .826201   |
  |   .6629843 +  .4677801i  |   .811398   |
  |   .6629843 -  .4677801i  |   .811398   |
  |  -.5342695 +  .5728215i  |   .783306   |
  |  -.5342695 -  .5728215i  |   .783306   |
  |  -.3369963 +  .6666839i  |   .747017   |
  |  -.3369963 -  .6666839i  |   .747017   |
  |  -.6519442               |   .651944   |
  |  -.1099588 +  .5898284i  |    .59999   |
  |  -.1099588 -  .5898284i  |    .59999   |
  |   .5363535 +  .1060582i  |   .546739   |
  |   .5363535 -  .1060582i  |   .546739   |
  |   .2438972 +  .3671963i  |   .440816   |
  |   .2438972 -  .3671963i  |   .440816   |
  +----------------------------------------+
   All the eigenvalues lie inside the unit circle.
   VAR satisfies stability condition.
  • All modules are below 1, so the VAR is stable

  • Let’s test if our policy instrument has any effect on the macroeconomic variables:
 testparm D.lrmbase
 ( 1)  [D_lrgrossinv]D.lrmbase = 0
 ( 2)  [D_lrconsump]D.lrmbase = 0
 ( 3)  [D_lrgdp]D.lrmbase = 0

           chi2(  3) =    9.35
         Prob > chi2 =    0.0249
  • It does, we rejet the lack of statistical significance

  • Creating tables of IRFs and OIRFs
  • 4 quarters into the future (2006-2008)
  • We focus on investment effects on consumption

 irf create myfirst, step(4) set(file1, replace) 
 irf table irf oirf , impulse(D.lrgrossinv) response(D.lrconsump) noci stderror
(file file1.irf created)
(file file1.irf now active)
(file file1.irf updated)


Results from myfirst

--------------------------------------------------------
         |      (1)         (1)         (1)         (1)  
    Step |      irf        S.E.        oirf        S.E.  
---------+----------------------------------------------
       0 |        0           0     .003338     .000422
       1 |  .016146     .036744     .000816     .000443
       2 | -.010985     .036705     .000871     .000448
       3 | -.019557     .037833      .00002     .000452
       4 |  .039791     .037741     .000335     .000444
--------------------------------------------------------
(1) irfname = myfirst, impulse = D.lrgrossinv, and response = D.lrconsump.

  • Note that the IRF predicts non-statistically significant effects as per their S.E.
  • The orthogonal IRF seem more important up to the 2 quarter. OIRFs assume that investment may have immediate echos (at t=0) in GDP and consumption itself. This explains the 0.3% effect on consumption at t=0, the period of the impulse/shock.
  • There must be an instantaneous effect at t=0 on GDP as well… let’s retrieve it…

 irf create myfirst, step(4) set(file2, replace) 
 irf table irf oirf , impulse(D.lrgrossinv) response(D.lrgdp) noci stderror
(file file2.irf created)
(file file2.irf now active)
(file file2.irf updated)


Results from myfirst

--------------------------------------------------------
         |      (1)         (1)         (1)         (1)  
    Step |      irf        S.E.        oirf        S.E.  
---------+----------------------------------------------
       0 |        0           0     .004515     .000461
       1 |  .151642     .041742     .002689     .000527
       2 |  .058602     .044827     .001645     .000541
       3 | -.097524     .045994    -.000678     .000549
       4 |  .015587     .045956     .000767      .00055
--------------------------------------------------------
(1) irfname = myfirst, impulse = D.lrgrossinv, and response = D.lrgdp.

The more realistic OIRFs shows that a shock on investment (impulse) at t=0 implies a parallel impulse on gdp of 0.45% at t=0. This additional push, although small, together with the 0.3% on consumption at t=0, create a new trajectory for consumption. At t=2, consumption grew 0.08%(statistically significant S.E. 0.44%) whereas the standard IRF never went beyond 0.04% (non statistically significant)


  • Whether an OIRF or an IRF should be preferred is a matter of the specific economic structure under analysis. Under certain conditions, it can be reasonable to assume that shocks/impulses, such as policy interventions will not imply inmediate contagions. In others, economic agents may very well anticipate the effects of such policies, thus creating simultaneous reactions at t=0.

Exercise (midterm bonus)

  • Chose a country or a set of variables of your interest and perform an IRF and OIRF analysis. Provide some comments on the effects of your choice.

  • Explain which, either IRF or OIRFs, makes more sense to your case.