bgvar {BGVAR} | R Documentation |
Estimates a Bayesian GVAR with either the Stochastic Search Variable Selection (SSVS), the Sims and Zha prior, or the Normal-Gamma prior with stochastic volatility.
bgvar(Data,W,Wex.restr=NULL,saves=5000,burns=5000,plag=2,hyperparm=NULL,Cpu=4,prior="SSVS",save_thin=.1,eigen=FALSE,logfile=FALSE,stats=FALSE,trend=FALSE,trim=NULL,SV="SV.M",ea.weights=NULL,OC.weights=NULL,variable.list=NULL)
Data |
A list of length N that contains the data. Each element of the list refers to a country. The number of columns (i.e., variables) in each country model can be different. The rows (i.e., number of time observations), however, need to be the same for each country. |
W |
An N times N weight matrix with 0 elements on the diagonal and row sums that sum up to unity or a list of weight matrices. See the help files for |
Wex.restr |
A character vector that contains variables that should only be specified as weakly exogeneous if not contained as endogeneous variable in a particular country. An example that has often been used in the literature is to place these restrictions on nominal exchange rates. Default is |
saves |
Number of draws saved. |
burns |
Number of burn-ins. |
plag |
Number of lags used (the same for domestic, exogenous and weakly exogenous variables). |
hyperparm |
Is a list object that defines the hyperparameters when the prior is set to either
|
Cpu |
The number of computer cores used to estimate the model. If Cpu>1 then the package snowfall is involved and the gvar is estimated using parallel computation. |
prior |
Either "SSVS", "SIMS" or "NG". See Details below. |
save_thin |
Is a thinning interval which grabs save_thin percent of your posterior output. As a rule of thumb, workspaces get large if save_thin*saves>500. |
eigen |
Set to TRUE if you want to compute the largest eigenvalue of the companion matrix for each posterior draw. If the modulus of the eigenvalue is significantly larger than unity, the model is unstable. |
logfile |
The logfile logs the start of the estimation of the country models and the start of stacking the models together. |
stats |
If |
trend |
set to |
trim |
If |
SV |
If set to |
ea.weights |
To model the common monetary policy in the euro area, it is possible to augment the GVAR countries by a country model for the ECB. It is important that this country model is labeled 'EB'. Akin to Georgidas (2015) one can use a Taylor rule to determine interest rates in the euro area. The Taylor rule typically relates short-term interest rates to a weighted average of output |
OC.weights |
This feature is very similar to |
variable.list |
In case |
We provide two priors, the SSVS and the Sims and Zha prior, the former has been implemented for global VARs in Feldkircher and Huber (2016) and the latter in Crespo Cuaresma et al. (2016). Please consult these references for more details on the specification. In the following we will briefly explain the difference between the two priors. For that purpose it proves convenient to work with the stacked matrix of coefficients for country i, Ξ_i = (a_{i,0},a_{i,1},vec(ψ_{i,1})', vec(Λ_{i,0})',vec(Λ_{i,1})')'. The SSVS-prior adovacted in George et al. (2008) does model selection by shrinking "unimportant" coefficients to zero. More precisely, it assumes a mixture normal prior on each coefficient
Ξ_{i,j}|δ_{i,j} \sim δ_{i,j} \mathcal{N}(0,τ_{i,0}^2) + (1-δ_{i,j})\mathcal{N}(0,τ_{i,1}^2)
where δ_{i,j} is a binary random variable which equals 1 if variables j is included in country model i and zero otherwise. The above mixture prior belongs to the class of 'spike and slab' priors which are frequently used for Bayesian variable selection. Here, we follow George et al. (2008) and choose a hierarchical setting in which δ_{i,j} is a random variable that has to be estimated. Typically, τ_{i,0} >> τ_{i,1}, which implies that the 'spike' is tightly centered at zero. Variable selection is based on the probability of assigning the corresponding regression effect to the 'slab' component. That is, for small coefficients the 'spike' component applies, pushing the associated posterior estimate more strongly towards zero. For the remaining coefficients, the slab component resembles a non-informative prior that has little impact on the posterior. Following George et al. (2008) we set the prior variances for the normal distributions in a semi-automatic fashion. This implies scaling the mixture normal with the OLS standard errors of the coefficients for the full model.
The Sims and Zha prior combines three so-called random walk priors assuming that under the prior model, the variables in the system follow simple random walks. These are the dummy initial observation prior (sims, 1992) which pushes the variables in the country-specific VAR towards their unconditional (stationary) mean, or toward a situation where there is at least one unit root present, the "sum of coefficients" prior, which softly forces the posterior distribution towards a specification in first differences. This implies that coefficients associated with own, lagged variables in each equation should sum to unity while other coefficients are being pushed towards zero and finally the Minnesota prior (Doan,) that punishes higher lag orders. As in Sims and Zha (1998) and Crespo Cuaresma et al. (2016) the hyperparameters are chosen by maximizing the marginal likelihood of the individual country models a-priori with respect to the hyperparameters. This implies that no user-input is needed when prior="SIMS"
.
args
is a list object that contains the arguments submitted to function bgvar
.
xglobal
is a matrix object of dimension T times N (T # of observations, K # of variables in the system).
x
is a matrix object with dimension K times (T-plag).
ccode
is a character vector returning the names of the countries.
gW
The global weight matrix. It is a list, with N
entries, each of which contains an Matrix
object.
country.res
A matrix that contains the posterior mean of the country models' residuals. The residuals have been obtained as a running mean and thus always relate to the full set of posterior draws. This implies that
in case you have opted for trimming the draws the residuals do not correspond to the posterior draws of the "trimmed" coefficients. This is a storage problem, rather than a statistical problem. Experiments, however, show that residual properties (autocorrelation, cross-sectional correlation) of trimmed and reported residuals are close.
stacked.results
S_large
is a three-dimensional array (K times K times saves) of the (block-diagonal) posterior variance covariance matrix.
F_large
is a four-dimensional array (K times K times lags times saves) of the coefficients.
Ginv_large
is a three-dimensional array (K times K times saves) of the inverse of the G matrix.
ALPHA_large
is a three-dimensional array (K times K+1 times saves) of the posterior estimates for the K coefficients plus a global constant.
globalLik
in case stats="TRUE"
, returns for each posterior draw the loglikelihood of the global model.
F.eigen
in case eigen="TRUE"
, returns a vector that contains for each posterior draw the modulus of the largest eigenvalue of the companion matrix.
trim.info
is a character vector. Contains information regarding the nr. of stable draws out of total (thinned) draws.
Esperience shows that trim=1.05
seems a reasonable choice when working with data in levels to generate stable impulse responses.
cc.results
coeffs
is a list object of length N
. Each entry in the list corresponds to one country model and contains a matrix with the posterior median of the estimated coefficients. Columns of the matrix correspond to an equation in the country model (i.e., the dependent variable) and rows to coefficient estimates of the explanatory variables.
res
is a matrix of dimension (T-p times K) and contains the posterior median of the residuals of the cross-country models.
PIP
in case prior="NG"
returns a list object. The first slot in the list pips
, is a list of length N
and contains the posterior inclusion probabilities of the country models. The second slot in the list, named avg.pips
yields simple averages (over the country models where a particular variable has been included) of the posterior inclusion probabilities.
vola
is a list object of length N
. Each slot of the list contains a matrix of dimension (T-p times k_i) with k_i denoting the number of endogeneous variables in country i.
kappa
in case prior="NG"
, returns a matrix of dimension (p+1 times 2). The first column contains the posterior shrinkage parameter associated to endogeneous variables, and the second to weakly and exogenoues variables. Rows refer to different degrees of shrinkage per lag of the variables.
a_tau
in case prior="NG"
, returns a matrix of dimension (p+1 times 2). The first column contains the posterior of the parameter that governs the heaviness of the tails of the marginal prior distribution of the coefficients associated to endogeneous variables, and the second to weakly and exogenoues variables. Rows refer to different degrees of shrinkage per lag of the variables.
Martin Feldkircher and Florian Huber
Crespo Cuaresma, J., Feldkircher, M. and F. Huber (2016) Forecasting with Global Vector Autoregressive Models: A Bayesian Approach. In: Journal of Applied Econometrics, Vol. 31, Issue 7, pp. 1371-1391.
Doan, T. R., Litterman, B. R. and C. A. Sims (1984) Forecasting and Conditional Projection Using Realistic Prior Distributions. In: Econometric Reviews 3, pp. 1-100.
Dovern, J., Feldkircher, M. and F. Huber (2016) Does joint modelling of the world economy pay off? Evaluating multivariate forecasts from a Bayesian GVAR. In: Journal of Economic Dynamics and Control, Volume 70, September 2016, pages 86-100.
Feldkircher, M. and F. Huber (2016) The International Transmission of US Shocks - Evidence from Bayesian Global Vector Autoregressions. In: European Economic Review, Vol. 81, pages 167-188.
George, E.I., Sun, D. and S. Ni (2008) Bayesian stochastic search for var model restrictions. In: Journal of Econometrics, Vol. 142, pp. 553-580.
Georgiadis, G. (2015) Examining asymmetries in the transmission of monetary policy in the euro area: Evidence from a mixed cross-section global VAR model. In: European Economic Review, Vol. 75, pp. 195-215.
Huber, F. and M. Feldkircher (2016) Adaptive Shrinkage in Bayesian Vector Autoregressive Models. In: Journal of Business and Economic Statistics, http://dx.doi.org/10.1080/07350015.2016.1256217, forthcoming.
Pesaran, M.H., Schuermann T. and S.M. Weiner (2004) Modeling Regional Interdependencies Using a Global Error-Correcting Macroeconometric Model. In: Journal of Business and Economic Statistics, American Statistical Association Vol. 22, pp. 129-162.
Sims, C. A. (1992) Bayesian Inference for Multivariate Time Series with Trend. In: Mimeo, presented at the American statistical Association meeting.
Sims, C.A. and T. Zha (1998) Bayesian Methods for Dynamic Multivariate Models. In: International Economic Review Vol. 39, pp. 949-968.
library(BGVAR) # replicate Feldkircher and Huber (2016) using 4 cpu cores with trade based weights data(eerData) Hyperparm <- list(tau0=0.1,tau1=3,kappa0=0.1,kappa1=7,a_i=0.01,b_i=0.01,p_i=0.5,q_ij=0.5) model.ssvs<-bgvar(Data=eer.data,W=W.trade0012,saves=100,burns=100,plag=1,hyperparm=Hyperparm,Cpu=4,prior="SSVS",save_thin=1,eigen=TRUE,logfile=FALSE,stats=TRUE,SV=NULL) print.bgvar(model.ssvs) # Sims Zha prior and two different weight matrices and no SV # weights for first variable set tradeW.0012, for second finW0711 variable.list<-list();variable.list$real<-c("y","Dp","tb");variable.list$fin<-c("stir","ltir","rer") model.SIMS<-bgvar(Data=eer.data,W=W.list[c("tradeW.0012","finW0711")],saves=100,burns=100,plag=1,hyperparm=Hyperparm,Cpu=4,prior="SIMS",save_thin=1,eigen=TRUE,logfile=FALSE,stats=TRUE,SV=NULL, variable.list=variable.list) print.bgvar(model.SIMS) # monthly data set, euro area single countries data(monthlyData) hyperparm<-list(c_tau = 0.01, d_tau = 0.01,e_lambda=1.5,d_lambda=1, prmean=0,a_i=0.01,b_i=0.01,a_start=.6,sample_A=FALSE)#standard setting model.ng<-bgvar(Data=new.data,W=W,saves=1000,burns=1000,plag=2,hyperparm=hyperparm,Cpu=4,prior="NG",save_thin=0.5,eigen=TRUE,stats=TRUE,SV="SV.M") print.bgvar(model.ng)