Tuesday, September 23, 2014

Canned VAR code for Stata AND Matlab [Data]


I was hunting around for some VAR code so I don't have to write my own; I find the following. 


http://www.mathworks.com/matlabcentral/fileexchange/34358-a-small-structural-var-package-for-impulse-response-analysis/content/estim.m

http://waynecain.blogspot.com/2011/03/impulse-response-function-in-stata.html

 

The first link takes you to the download page for some Matlab code. There's a example.m showing how things work.


The second link describe how you can run VAR using the build in Stata functions. The page is worth a read, but it summarize to doing the following:

 

tsset dates

varsoc var1 var2 var3, maxlag(12)

  /* to test model lag to use */

var var1 var2 var3, lags(1/3)

  /* estiamte */

irf create order1, step(12) set(myirf1)

irf graph oirf, impulse(var1) response(var2)

  /* make some pretty impulse response graph(s) */


I ran the two set of code using the same data from the Matlab package. The results are similar.