VAR with time-varying parameters and stochastic volatility

Questions and discussions on Time Series Analysis

VAR with time-varying parameters and stochastic volatility

Postby tclark » Mon Jul 26, 2010 9:07 pm

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.
Attachments
REPPRIMICERI_10.RGF
plot (Rats 7.3) of posterior estimates of equation volatilities
(9.25 KiB) Downloaded 523 times
data.UScurrent.xls
data file
(55 KiB) Downloaded 532 times
VARTVPKSC.src
procedure file that does most calculations
(31.34 KiB) Downloaded 523 times
repPrimiceri.prg
program file, which calls data file and procedure
(26 KiB) Downloaded 553 times
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
tclark
 
Posts: 35
Joined: Wed Nov 08, 2006 4:20 pm

Re: VAR with time-varying parameters and stochastic volatility

Postby ac_1 » Tue Jul 27, 2010 12:36 pm

Todd, Your "REPPRIMICERI_10.RGF" should be a "*.RPF" file ?? I can't get it to read into RATS 7.3.
ac_1
 
Posts: 56
Joined: Thu Apr 15, 2010 6:30 am
Location: Surrey, England, UK

Re: VAR with time-varying parameters and stochastic volatility

Postby tclark » Tue Jul 27, 2010 12:48 pm

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.
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
tclark
 
Posts: 35
Joined: Wed Nov 08, 2006 4:20 pm

Re: VAR with time-varying parameters and stochastic volatility

Postby ac_1 » Tue Jul 27, 2010 2:17 pm

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:
ac_1
 
Posts: 56
Joined: Thu Apr 15, 2010 6:30 am
Location: Surrey, England, UK

Re: VAR with time-varying parameters and stochastic volatility

Postby luching » Wed Oct 20, 2010 6:15 pm

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.
luching
 
Posts: 31
Joined: Mon Jun 07, 2010 4:05 pm

Re: VAR with time-varying parameters and stochastic volatility

Postby luching » Thu Oct 21, 2010 12:25 pm

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.
luching
 
Posts: 31
Joined: Mon Jun 07, 2010 4:05 pm

Re: VAR with time-varying parameters and stochastic volatility

Postby TomDoan » Thu Oct 21, 2010 1:04 pm

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.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: VAR with time-varying parameters and stochastic volatility

Postby luching » Thu Oct 21, 2010 1:10 pm

Thanks. Could you suggest a way to circumvent the earlier problem with DLM? Should I just skip that draw? How can I "trap" it?
luching
 
Posts: 31
Joined: Mon Jun 07, 2010 4:05 pm

Re: VAR with time-varying parameters and stochastic volatility

Postby tclark » Thu Oct 21, 2010 1:37 pm

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.
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
tclark
 
Posts: 35
Joined: Wed Nov 08, 2006 4:20 pm

Re: VAR with time-varying parameters and stochastic volatility

Postby TomDoan » Thu Oct 21, 2010 2:52 pm

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.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: VAR with time-varying parameters and stochastic volatility

Postby tclark » Thu Oct 21, 2010 3:01 pm

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.
Attachments
Archive.zip
(26.45 KiB) Downloaded 278 times
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
tclark
 
Posts: 35
Joined: Wed Nov 08, 2006 4:20 pm

Re: VAR with time-varying parameters and stochastic volatility

Postby dalibor » Mon Nov 15, 2010 3:57 pm

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
dalibor
 
Posts: 1
Joined: Mon Nov 15, 2010 3:51 pm

Re: VAR with time-varying parameters and stochastic volatility

Postby tclark » Mon Nov 15, 2010 5:43 pm

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).
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
tclark
 
Posts: 35
Joined: Wed Nov 08, 2006 4:20 pm

Re: VAR with time-varying parameters and stochastic volatili

Postby jonasdovern » Thu Jan 12, 2012 4:11 am

Has there been any suggestion on how to fix the "1.#QNANe+000"-problem in the meantime?
jonasdovern
 
Posts: 68
Joined: Sat Apr 11, 2009 10:30 am

Re: VAR with time-varying parameters and stochastic volatili

Postby ege_man » Tue Jul 24, 2012 3:58 pm

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
ege_man
 
Posts: 4
Joined: Sat Jul 07, 2012 2:39 pm

Next

Return to Other Time Series Analysis

Who is online

Users browsing this forum: No registered users and 0 guests