Time varying structural VAR
rvar=Hetero_TVP_VAR(nlag,endo,nrep,nburn,prior,libsave,nrep_max,arg1,...,argn)
* nlag = a scalar, the # of lags of the VAR
* endo = either a string vector or a list collecting the names of the endogenous variables of the VAR
* nrep = # of replications taken into account
* nburn = # of replications not taken into account ("burned": the total # of draws is therefore nrep+ nburn)
* prior = a prior tlist
* tau = size of the training sample or [] if ts_priori is set to %f
* consQ = multiplicative factor used for the prior of the variance-matrix of the tvp
* libsave = name of the library where the resultys will be stored
* nrep_max = maximum number of iterations for a storing file
* arg1,...,argn = optional arguments that can be:
- 'exo=list(exo1,..., exon) if the user wants to add exogenous variables to the VAR, exoi then collects the exogenous variables of equation i
- 'nocte' if the user does not want constants in the VAR
- 'dropna' if the user wants to drop NA values from the data instead of generating an error
* rvar = a results tlist with:
- rvar('meth') = 'heteroskedastic tvp var'
- rvar('y') = matrix, the endogenous variables
- rvar('nobs') = # of observations used for estimation
- rvar('nendo') = # of endogenous variables
- rvar('nrep') = # of replications taken into account for the calculation of psoterior densities
- rvar('nburn') = # of replications not taken into account for the calculation of psoterior densities
- rvar('nlag') = # of lags in the VAR
- rvar('A_0_prmean') = mean of the tvp prior for the A(t) coefficients
- rvar('B_0_prvar') = variance of the tvp prior for the A(t) coefficients
- rvar('B_0_prmean') = mean of the tvp prior for the B(t) coefficients
- rvar('B_0_prvar') = variance of the tvp prior for the B(t) coefficients
- rvar('logsigma_prmean') = mean of the tvp prior for the log of the Sigma(t) variances
- rvar('logsigma_prvar') = variance of the tvp prior for the log of the Sigma(t) variances
- rvar('Q_prmean') = mean of the tvp prior for the Q variance matrix
- rvar('Q_prvar') = variance of the tvp prior for the Q variance matrix
- rvar('W_prmean') = mean of the tvp prior for the W variance matrix
- rvar('W_prvar') = variance of the tvp prior for the W variance matrix
- rvar('S_prmean') = mean of the tvp prior for the S variance matrix
- rvar('S_prvar') = variance of the tvp prior for the S variance matrix
- rvar('Bt_postmean') = estimated matrix of the B(t) coefficients (averaged over the replications)
- rvar('At_postmean') = estimated matrix of the A(t) coefficients (averaged over the replications)
- rvar('Sigt_postmean') = estimated matrix of the Sigma(t) coefficients (averaged over the replications)
- rvar('Qmean') = estimated value of the Q variance matrix (averaged over the replications)
- rvar('Smean') = estimated value of the S variance matrix (averaged over the replications)
- rvar('Wmean') = estimated value of the W variance matrix (averaged over the replications)
- rvar('Sigmamean') = estimated variance of the shocks (averaged over the replications)
- rvar('.dat Bt') = a string vector, the names of the databases where all B(t) draws are stored
- rvar('.dat At') = a string vector, the names of the databases where all A(t) draws are stored
- rvar('.dat Sigmat') = a string vector, the names of the databases where all draws of Sigmat are stored
- rvar('.dat Htstd') = a string vector, the names of the databases where the estimated variance of the shocks are stored
- rvar('.dat Q') = a string vector, the names of the databases where all Q draws are stored
- rvar('.dat S') = a string vector, the names of the databases where all S draws are stored
- rvar('.dat W') = a string vector, the names of the databases where all W draws are stored
- rvar('namey') = name of the y variable
- rvar('namex') = list of names of the x variables
- rvar('prests') = boolean indicating the presence or absence of a time series in the regression
- rvar('dropna') = boolean indicating if NAs have been dropped
- rvar('bounds') = if there is a timeseries in the regression, the bounds of the regression
- rvar('nonna') = vector indicating position of non-NAs
************************************************************
The model is: Y(t) = B0(t) + B1(t)xY(t-1) + ... + Bp(t)xY(t-p) + e(t) with e(t) ~ N(0,SIGMA(t)), and L(t)'' x SIGMA(t) x L(t) = D(t)*D(t), _ _ | 1 0 0 ... 0 | | L21(t) 1 0 ... 0 | L(t) = | L31(t) L32(t) 1 ... 0 | | ... ... ... ... ... | |_ LN1(t) ... ... LN(N-1)(t) 1 _| and D(t) = diag[exp(0.5 x h1(t)), .... ,exp(0.5 x hn(t))].The state equations are B(t) = B(t-1) + u(t),
u(t) ~ N(0,Q) l(t) = l(t-1) + zeta(t), zeta(t) ~ N(0,S) h(t) = h(t-1) + eta(t), eta(t) ~ N(0,W) where: B(t) = [B0(t),B1(t),...,Bp(t)]' l(t)=[L21(t),...,LN(N-1)(t)]' h(t) = [h1(t),...,hn(t)]'.stacksize('max') load(GROCERDIR+'\data\primiceri.dat') mkdir(GROCERDIR+'\temp') nlag=2 bounds('1953q3','1963q2') prior=tvpvar_prior0(nlag,4,4,0.01,0.01,0.1,['Inflation';'Unemployment';'rate_3m']) bounds('1963q3','2001q3') res=Hetero_TVP_VAR(nlag,['Inflation';'Unemployment';'rate_3m'],10000,2000,prior,path,2000) // This example reproduces the results of the paper by Primeceri (2005), slightly modified // by the corridendum by Del Negro and Primiceri (2014): the varaibles are United states inflation // inflation, unemployment and 3 months interest rates, collected in GROCERDIR+'\data\primiceri.dat') // database. The number of lags is set to 2, number of useful draws to 10000, number of discarded // drawss to 2000 and number of draws per database to 2000. Databases are stored into folder // GROCERDIR+'\temp'. Priors have been set in function tvpvar_prior0, with dilatation factors // applied to the ols estimates of A0 and B0 over the training sample '1953q3' to '1963q2' set to // 4, the the dilatation factors applied, squared, to (n+1) for the inverse Wishart prior of W, Q and // S set 0.01, 0.01 and 0.1 respectively | ![]() | ![]() |