Page 1 of 2

VAR with time-varying parameters and stochastic volatility

PostPosted: Mon Jul 26, 2010 9:07 pm
by tclark
Following up on a previous post by Tom Doan, I have attached code and data for estimation of a VAR with time-varying parameters and stochastic volatility. This roughly replicates the basic results of Giorgio Primiceri, (2005), "Time Varying Structural Vector Autoregressions and Monetary Policy," Review of Economic Studies, 72, 821-852.

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Tue Jul 27, 2010 12:36 pm
by ac_1
Todd, Your "REPPRIMICERI_10.RGF" should be a "*.RPF" file ?? I can't get it to read into RATS 7.3.

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Tue Jul 27, 2010 12:48 pm
by tclark
Sorry, I forgot about the change in naming convention. The .RGF file is a RATS graphics file, not a program file. The program file is the one with the extension .prg.

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Tue Jul 27, 2010 2:17 pm
by ac_1
tclark wrote:Sorry, I forgot about the change in naming convention. The .RGF file is a RATS graphics file, not a program file. The program file is the one with the extension .prg.


Opps! Nop my error - apologies! :oops:

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Wed Oct 20, 2010 6:15 pm
by luching
Dear Tom/Todd,

I am trying to use these codes in a different context.

The DLM routine, at some point in the MCMC draws, spits out "1.#QNANe+000". I tried with different priors, different transformation of the data and also checking for explosive draws. It does not seem to work. It usually starts in the draw of the alpha's, sometimes in delta's. Any advice?

Luching.

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Thu Oct 21, 2010 12:25 pm
by luching
I think the problem comes from a cholesky decomposition step in the carter kohn routine embedded in DLM. So, in general I checked %decomp command. I am not too sure how RATS does cholesky decompositions, but it seems to give me answers where it shouldn't. For instance,

A=[1,1;1,1] returns [1,1;0,0] as cholesky in RATS. Whereas, in MATLAB it returns a "non positive definite" error.

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Thu Oct 21, 2010 1:04 pm
by TomDoan
luching wrote:I think the problem comes from a cholesky decomposition step in the carter kohn routine embedded in DLM. So, in general I checked %decomp command. I am not too sure how RATS does cholesky decompositions, but it seems to give me answers where it shouldn't. For instance,

A=[1,1;1,1] returns [1,1;0,0] as cholesky in RATS. Whereas, in MATLAB it returns a "non positive definite" error.


That's Matlab's problem, not ours. 1,1|0,0 is the Choleski factor of 1,1|1,1.

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Thu Oct 21, 2010 1:10 pm
by luching
Thanks. Could you suggest a way to circumvent the earlier problem with DLM? Should I just skip that draw? How can I "trap" it?

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Thu Oct 21, 2010 1:37 pm
by tclark
I don't know if this does you any good, but I have had less trouble with that type of error (on my machine, it shows up as values of "NaN") with estimating these types of models on a Linux server than on a desktop.

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Thu Oct 21, 2010 2:52 pm
by TomDoan
A problem value like that should be caught with a check for %VALID. What you're seeing is a de-normal different from the one that we use for representing NA's internally, but we check for all the de-normal codes. If someone could send an example (program, data and a SEED) that can reproduce it, we'll take a look.

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Thu Oct 21, 2010 3:01 pm
by tclark
That would be great. I have attached a .zip file with a simpler example, of using Gibbs sampling to estimate a local level model. That said, the problem is somewhat idiosyncratic. If it doesn't show up in your checking, I can send code for the full TVP-stochastic volatility example, which more systematically yields the problem.

More specifically, in some programs I have written that take advantage of DLM in generating Gibbs sampling estimates of models with some form of time-varying parameters, I am finding that the same program with the same settings (including a pre-set seed value) will run fine in one attempt but then generate no results -- just values of "nan" -- in another. In some limited testing, there also seems to be some sensitivity to the platform. The same program with the same settings will generate just "nan" values on my Mac (7.3) but then run okay in Windows (7.2) or Linux (7.3), but I have also run into the "nan" no-results in Linux.

As to this example, in one run, I got no results (given in locallevel.NAN.out). In another run of exactly the same program, a few minutes later, I got results (given in locallevel.noNAN.out). I ran both on my Mac (batch mode), with v.7.3 of RatsPro.

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Mon Nov 15, 2010 3:57 pm
by dalibor
Hi
I now this is RATS forum, but do you know if there exists Matlab version of the code to replicate Primiceri's results?
Thanks

Re: VAR with time-varying parameters and stochastic volatility

PostPosted: Mon Nov 15, 2010 5:43 pm
by tclark
Gary Koop has posted on his website Matlab programs for estimating Primiceri-type models with time-varying parameters and stochastic volatility. The supplementary materials published with the 2010 American Economic Journal: Macroeconomics paper by Cogley, Primiceri, and Sargent includes Matlab code for estimating a related model, that of Cogley and Sargent (2005, Review of Economic Dynamics).

Re: VAR with time-varying parameters and stochastic volatili

PostPosted: Thu Jan 12, 2012 4:11 am
by jonasdovern
Has there been any suggestion on how to fix the "1.#QNANe+000"-problem in the meantime?

Re: VAR with time-varying parameters and stochastic volatili

PostPosted: Tue Jul 24, 2012 3:58 pm
by ege_man
Dear Tom,
I would like to compare the linear and TVP-VAR models in terms of godness of fit. Is there any available test for this with RATS?
Thanks