Recursive BVAR help
Posted: Mon Sep 22, 2014 2:55 pm
Dear all,
I have been given a rats .prg from a co-author and I am slightly confused, perhaps you can help - I would be eternally grateful. The goal is to create recursive (out of sample) forecasts from a BVAR. I have generated four random variables from 1980q1:2012q4 to help to make the exposition clearer. In the first example dataset (example1.xls), all data entries are present. This is the following code which attempts to generate pseudo real time OOS forecasts:
Which I thought would be correct. However, if we compare this with the second code file below, and instead use the data in the example2.xls which is for just one recursion, and is missing all of the out of sample data (to fit in with our ex-ante 'psuedo realtime exercise', we can see that for the first recursion (in-sample estimation from 1980q1:2003q4 and the first OOS for 8 steps is 2004q1
q4), the results are markedly different from the first forecast produced from the above code when 'window = 1'.
It is my suspicion that the program is not creating dynamic OOS forecasts from recursive re-estimations, but is instead using in-sample static 'fits' for a model estimated across the whole period. However, this is contradictory to my understanding of the FORECAST command.
Attached are the two datasets, and any help would be just great if you can spare the time to consider the matter.
I have been given a rats .prg from a co-author and I am slightly confused, perhaps you can help - I would be eternally grateful. The goal is to create recursive (out of sample) forecasts from a BVAR. I have generated four random variables from 1980q1:2012q4 to help to make the exposition clearer. In the first example dataset (example1.xls), all data entries are present. This is the following code which attempts to generate pseudo real time OOS forecasts:
Code: Select all
* Set Up Data
open data example1.xls
calendar(q) 1980
data(format=XLS,ORGANIZATION=COLUMNS) 1980:1 2012:4 var1 var2 var3 var4
procedure runtheil
option choice type 1 symmetric general
option rect matrix
option vector mvector
option real tightness
option real other
option real decay
option string window
local integer time
system(model=EXAMPLEMODEL) ;*<<<<<<<
variables var1 var2 var3 var4
lags 1 to 2 ;*<<<<<<<
det constant
specify(tightness=tightness,type=type,matrix=matrix,mvector=mvector,decay=decay) other
end(system)
theil(model=EXAMPLEMODEL,SETUP) 177 8 2012:4 ;*<<<<<<<
estimate(noprint) * 2003:4 ;*<<<<<<<
theil
do time=2004:1,2012:4 ;*<<<<<<<
kalman
theil
end do time
theil(dump,window=window)
end
@runtheil(tightness=0.1237,other=1,decay=1,window="BVAR")
FORECAST(MODEL=EXAMPLEMODEL,window="1") 4 8 2004:1
FORECAST(MODEL=EXAMPLEMODEL,window="2") 4 8 2004:2
FORECAST(MODEL=EXAMPLEMODEL,window="3") 4 8 2004:3
FORECAST(MODEL=EXAMPLEMODEL,window="4") 4 8 2004:4
FORECAST(MODEL=EXAMPLEMODEL,window="5") 4 8 2005:1
FORECAST(MODEL=EXAMPLEMODEL,window="6") 4 8 2005:2
FORECAST(MODEL=EXAMPLEMODEL,window="7") 4 8 2005:3
FORECAST(MODEL=EXAMPLEMODEL,window="8") 4 8 2005:4
FORECAST(MODEL=EXAMPLEMODEL,window="9") 4 8 2006:1
FORECAST(MODEL=EXAMPLEMODEL,window="10") 4 8 2006:2
FORECAST(MODEL=EXAMPLEMODEL,window="11") 4 8 2006:3
FORECAST(MODEL=EXAMPLEMODEL,window="12") 4 8 2006:4
FORECAST(MODEL=EXAMPLEMODEL,window="13") 4 8 2007:1
FORECAST(MODEL=EXAMPLEMODEL,window="14") 4 8 2007:2
FORECAST(MODEL=EXAMPLEMODEL,window="15") 4 8 2007:3
FORECAST(MODEL=EXAMPLEMODEL,window="16") 4 8 2007:4
FORECAST(MODEL=EXAMPLEMODEL,window="17") 4 8 2008:1
FORECAST(MODEL=EXAMPLEMODEL,window="18") 4 8 2008:2
FORECAST(MODEL=EXAMPLEMODEL,window="19") 4 8 2008:3
FORECAST(MODEL=EXAMPLEMODEL,window="20") 4 8 2008:4
FORECAST(MODEL=EXAMPLEMODEL,window="21") 4 8 2009:1
FORECAST(MODEL=EXAMPLEMODEL,window="22") 4 8 2009:2
FORECAST(MODEL=EXAMPLEMODEL,window="23") 4 8 2009:3
FORECAST(MODEL=EXAMPLEMODEL,window="24") 4 8 2009:4
FORECAST(MODEL=EXAMPLEMODEL,window="25") 4 8 2010:1
FORECAST(MODEL=EXAMPLEMODEL,window="26") 4 8 2010:2
FORECAST(MODEL=EXAMPLEMODEL,window="27") 4 8 2010:3
FORECAST(MODEL=EXAMPLEMODEL,window="28") 4 8 2010:4
FORECAST(MODEL=EXAMPLEMODEL,window="29") 4 8 2011:1
FORECAST(MODEL=EXAMPLEMODEL,window="30") 4 8 2011:2
FORECAST(MODEL=EXAMPLEMODEL,window="31") 4 8 2011:3
FORECAST(MODEL=EXAMPLEMODEL,window="32") 4 8 2011:4
FORECAST(MODEL=EXAMPLEMODEL,window="33") 4 8 2012:1
FORECAST(MODEL=EXAMPLEMODEL,window="34") 4 8 2012:2
FORECAST(MODEL=EXAMPLEMODEL,window="35") 4 8 2012:3
FORECAST(MODEL=EXAMPLEMODEL,window="36") 4 8 2012:4
*
Code: Select all
* Set Up Data
*
open data example2.xls
calendar(q) 1980
data(format=XLS,ORGANIZATION=COLUMNS) 1980:1 2012:4 var1 var2 var3 var4
*
* RunTheil Procedure
* Needs modification of the lines tagged with ;*<<<<<<< to accomodate
* different models. Computes Theil U's for a VAR using either a
* symmetric or general prior.
*
* By setting TIGHTNESS to a large value (such as 2.00), you effectively
* eliminate the "Bayesian" part, and thus look at an OLS VAR.
*
* By setting OTHER to a very small value (such as .001), you effectively
* eliminate the "Vector" part, and thus look at an autoregression only.
*
procedure runtheil
option choice type 1 symmetric general
option rect matrix
option vector mvector
option real tightness
option real other
option real decay
option string window
*
local integer time
*
system(model=EXAMPLEMODEL) ;*<<<<<<<
variables var1 var2 var3 var4
lags 1 to 2 ;*<<<<<<<
det constant
specify(tightness=tightness,type=type,matrix=matrix,mvector=mvector,decay=decay) other
end(system)
*
theil(model=EXAMPLEMODEL,SETUP) 177 8 2012:4 ;*<<<<<<<
estimate(noprint) * 2003:4 ;*<<<<<<<
theil
do time=2004:1,2012:4 ;*<<<<<<<
kalman
theil
end do time
theil(dump,window=window)
end
*
***********************************************************************
*
@runtheil(tightness=0.1237,other=1,decay=1,window="BVAR")
FORECAST(MODEL=EXAMPLEMODEL,window="1") 4 8 2004:1
*
Attached are the two datasets, and any help would be just great if you can spare the time to consider the matter.