Helping with code of Primiceri (2005)
Posted: Wed Aug 12, 2015 10:31 pm
Hello!
I'm trying to use the TVP-VAR with Stochastic Volatility used in Primiceri (2005). I changed everything I thought I should (and I could) but after running to the @VARTVPKSC it said that there were not enough data in the training sample to fit prior.
Where should I change the setting? I attached my data file as well as the code. I'm using monthly data of domestic price, export price and exchange rate in 8 industries (1~8).
My RATs version is 9.0
Thank you.
I'm trying to use the TVP-VAR with Stochastic Volatility used in Primiceri (2005). I changed everything I thought I should (and I could) but after running to the @VARTVPKSC it said that there were not enough data in the training sample to fit prior.
Where should I change the setting? I attached my data file as well as the code. I'm using monthly data of domestic price, export price and exchange rate in 8 industries (1~8).
My RATs version is 9.0
Thank you.
Code: Select all
dis %ratsversion()
dis %dateandtime()
comp dropexpl = 0 ;* 0 to not drop explosive draws in MCMC
comp ndraws = 8000 ;* number of draws retained. total draws = burndraws + ndraws*skipinterval
comp burndraws = 5000
comp skipinterval = 2 ;* set this to 1 to not skip any draws in what is retained
comp usemedians = 1 ;* 1 to use posterior medians in most charts, 0 to use posterior means
comp commonscale = 0 ;* 1 to impose common scale in impulse response plots, 0 to not
grparm header 18 subheader 18 keylabeling 16
env nowshowgraphs gsave="repPrimiceri_*.rgf" gformat=rgf
comp nvar = 3 ;* number of variables in VAR
comp fixlags = 2 ;* fixed lag order in model
comp styr = 1980
cal(m) styr:1
comp stsmpl = styr:1
comp endsmpl = 2014:12 ;* "endsmpl" is the last observation period.
all stsmpl endsmpl
smpl stsmpl endsmpl
comp seedval = 44*48
seed seedval
********************************
******************************** reading in Koop's data
********************************
open data DataSet.2015.07.21.xls
data(for=xls,org=col) / ipi dp1 dp2 dp3 dp4 dp5 dp6 dp7 dp8 ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 neer1 neer2 $
neer3 neer4 neer5 neer6 neer7 neer8
close
***********************************************************
take the first diference of logarithm of each variables
***********************************************************
set x3 = ex6
set x1 = log(neer6)
set x2 = dp6
set dx1 = x1 - x1{1}
set dx2 = x2 - x2{1}
set dx3 = x3 - x3{1}
** for storing variable names, allocate label vector and order position of real variable
** IT'S A STRUCTRUAL VAR: different order of varibles give different outcome
dec vec[string] varlabels(nvar)
dec vec[ser] y(nvar)
comp k = 0
dofor i = dx1 dx2 dx3
comp k = k+1
set y(k) = i{0}
comp varlabels(k) = %l(i)
end do i
********************************
******************************** setting data sample, and weighting energy inflation
********************************
comp prenobs = 60 ;*Previous number of observation = 5 years
comp stpt = 1985:3
comp endpt = endsmpl
********************************
******************************** setting dimensions and prior stuff
******************************** Priors are same as in Primiceri.
sou(noecho) VARTVPKSC.src
** prior on VAR coefs (not used in this example)
dec vec meanfirstlag(nvar)
comp meanfirstlag = %const(0.)
** prior on time variation in coefficients (mean and IW df)
comp Q_priordf = prenobs
comp Q_priorscale = .0001
** prior on time variation in each equation's A coefficients (mean and IW df)
** (equation 1 stuff here not actually used)
dec vec[int] S_priordf(nvar)
do i = 1,nvar
comp S_priordf(i) = i
end do i
comp S_priorscale = .01
** prior on time variation in log volatilities, which are log st devs (mean and IW df)
comp priordfPhi = nvar+1
dec symm muPhi(nvar,nvar)
comp muPhi = %mscalar(0.0001)
** prior variance of initial value of volatility (mean set by procedure)
dec symm OmegaDelta0(nvar,nvar)
comp OmegaDelta0 = %mscalar(1.)
********************************
******************************** OLS estimation, full and pre-sample, just as checks
********************************
system(model=varmodel)
variables y
lags 1 to fixlags
det constant
end(system)
************ full sample
estimate(noftests) stpt endpt
comp compcoef = %modelcompanion(varmodel)
eigen(cvalues=cxvals,sort=absval) compcoef
dis 'largest eigen value in full sample = ' %real(%cabs(cxvals(1)))
comp OLSsigma = %sigma ;* will use this below to set fixed, common size of shocks
************ training sample
estimate(noftests) stpt-prenobs stpt-1
comp compcoef = %modelcompanion(varmodel)
eigen(cvalues=cxvals,sort=absval) compcoef
dis 'largest eigen value in training sample = ' %real(%cabs(cxvals(1)))
********************************
******************************** estimation, along with reporting of a limited set of posterior statistics
********************************
comp meanfirstlag = %const(.0)
comp cbar = .001
@VARTVPKSC(prmean,prinit,inclconst,doRsq,nodropexpl,noinformprior) y stpt endpt prenobs fixlags ndraws burndraws skipinterval meanfirstlag Q_priordf Q_priorscale $
S_priordf S_priorscale muDelta0 OmegaDelta0 muPhi priordfPhi cbar PiRes ARes Qres PhiRes LambdaRes stdevRes SRes RsqRes
dis %dateandtime()