Check stationarity of VAR

Questions and discussions on Vector Autoregressions
dennis0125hk
Posts: 15
Joined: Thu Apr 09, 2009 8:17 am

Check stationarity of VAR

Unread post by dennis0125hk »

I would like to implement a code to check whether the VAR is stationary or not. Given the VAR,

A(L)y_t = e_t

If the VAR is stationary, then det(A(z)) = 0 has all roots that lie outside unit circle. However, if one of the roots lies inside the unit circel, then the VAR is said to be non-stationary. I would like to implement a code to check the stationarity according to the rule.

The equation involves determinant of matrix which depends on z. I think of using %det to implement the code. However, the matrix considered depends on z, so it involves other commands as well. Is there any short command to implement this? Or I need to consider some other kinds of numerical methods to solve the problem?

Thanks for attention. I would be pleased if anyone can help me about this.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Check stationarity of VAR

Unread post by TomDoan »

Check out kpsw1.prg in the King, Plosser, Stock, Watson AER 1991 replication. It uses

eigen(cvalues=cvt) %modelcompanion(v3)

to get the eigenvalues of the companion matrix for the model, which is the set of roots (actually reciprocals of the roots) that you want.
apollon
Posts: 17
Joined: Thu Sep 30, 2010 8:01 am

Re: Check stationarity of VAR

Unread post by apollon »

It's good to know that RATS allows for that, though it would be great if there was a dedicated function for this.

dennis0125hk were you able to draft your function ?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Check stationarity of VAR

Unread post by TomDoan »

The problem you have is that the working definition of "stationary" can vary from situation to situation. Due to the possibility of roundoff error, a hard cut-off of 1.0 isn't a good idea. The typical cutoff choice is around .99 or .999, such as the following:

Code: Select all

   compute testroot=%modelcompanion(qualvar)
   eigen(cvalues=cv) testroot
   if %cabs(cv(1))>.999 {
      disp "VAR draw rejected"
      goto redraw
   }
The following will return the absolute value of the dominant root of a model, which you can then test as you need.

Code: Select all

function %ModelLargestRoot model
type model model
*
local vect[complex] cv
eigen(cvalues=cv) %modelcompanion(model)
compute %ModelLargestRoot=%cabs(cv(1))
end
apollon
Posts: 17
Joined: Thu Sep 30, 2010 8:01 am

Re: Check stationarity of VAR

Unread post by apollon »

Thanks so much for your promt reply. That would seem to be what I'm looking for.
I couldn't find kpsw1.prg anywhere though, can you pls advise ?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Check stationarity of VAR

Unread post by TomDoan »

It's in one of the paper replication folders: KPSW AER 1991
apollon
Posts: 17
Joined: Thu Sep 30, 2010 8:01 am

Re: Check stationarity of VAR

Unread post by apollon »

I got this now. Can you pls advise how to incorporate the two pieces of code you wrote into KPSW1.PRG ?
I tried by copying and pasting the first by changing model to v3 and I didn't see any output.
The second was giving me the error that "CV is not a PROCEDURE/FUNCTION Parameter". I then took it out
and pasted this line under your code: %ModelLargestRoot v3. I am now getting "Expected Instruction Here".
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Check stationarity of VAR

Unread post by TomDoan »

Sorry. I corrected the function above - it should have been local ... cv, not type ... cv

You would use it as follows (regarding the earlier test)

if %ModelLargestRoot(qualvar)>.999 {
disp "VAR draw rejected"
goto redraw
}
apollon
Posts: 17
Joined: Thu Sep 30, 2010 8:01 am

Re: Check stationarity of VAR

Unread post by apollon »

It still doesn't produce any output. Below is my modified var_1_2.prg:

Code: Select all

function %ModelLargestRoot model
type model model
*
local vect[complex] cv
eigen(cvalues=cv) %modelcompanion(model)
compute %ModelLargestRoot=%cabs(cv(1))
end

open data e1.dat
calendar(q) 1960
data(format=prn,org=columns,skips=6) 1960:01 1982:04 invest income cons
*
set dinc  = log(income/income{1})
set dcons = log(cons/cons{1})
set dinv  = log(invest/invest{1})
*
system(model=varmodel)
variables dinv dinc dcons
lags 1 2
det constant
end(system)
estimate(resids=unresids) * 1978:4

if %ModelLargestRoot(varmodel)>.001 {
disp "VAR draw rejected"
goto redraw
}
dis %ModelLargestRoot(varmodel)
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Check stationarity of VAR

Unread post by TomDoan »

Your function is working fine; you're just taking code out of a more complicated procedure which, for instance, has a "redraw" label. Just get rid of your faulty

if %ModelLargestRoot(varmodel)>.001 {
disp "VAR draw rejected"
goto redraw
}

and just leave the DISPLAY instruction at the end, and you'll see that it works correctly.
Post Reply