{bvarsv}R Documentation

Bayesian Analysis of a Vector Autoregressive Model with Stochastic Volatility and Time-Varying Parameters


Bayesian estimation of the flexible VAR model by Primiceri (2005) which allows for both stochastic volatility and time drift in the model parameters.

Usage, p = 1, tau = 40, nf = 10, pdrift = TRUE, nrep = 50000, 
nburn = 5000, thinfac = 10, itprint = 10000, save.parameters = TRUE, 
k_B = 4, k_A = 4, k_sig = 1, k_Q = 0.01, k_S = 0.1, k_W = 0.01, 
pQ = NULL, pW = NULL, pS = NULL)



Matrix of data, where rows represent time and columns are different variables. Y must have at least two columns.


Lag length, greater or equal than 1 (the default)


Length of the training sample used for determining prior parameters via least squares (LS). That is, data in Y[1:tau, ] are used for estimating prior parameters via LS; formal Bayesian analysis is then performed for data in Y[(tau+1):nrow(Y), ].


Number of future time periods for which forecasts are computed (integer, 1 or greater, defaults to 10).


Dummy, indicates whether or not to account for parameter drift when simulating forecasts (defaults to TRUE).


Number of MCMC draws excluding burn-in (defaults to 50000)


Number of MCMC draws used to initialize the sampler (defaults to 5000). These draws do not enter the computation of posterior moments, forecasts etc.


Thinning factor for MCMC output. Defaults to 10, which means that the forecast sequences (fc.mdraws, fc.vdraws, fc.ydraws, see below) contain only every tenth draw of the original sequence. Set thinfac to one to obtain the full MCMC sequence.


Print every itprint-th iteration. Defaults to 10000. Set to very large value to omit printing altogether.


If set to TRUE, parameter draws are saved in lists (these can be very large). Defaults to TRUE.

k_B, k_A, k_sig, k_Q, k_W, k_S, pQ, pW, pS

Quantities which enter the prior distributions, see the links below for details. Defaults to the exact values used in the original article by Primiceri.



Posterior means of coefficients. This is an array of dimension [M, Mp+1, T], where T denotes the number of time periods (= number of rows of Y), and M denotes the number of system variables (= number of columns of Y). The submatrix [, , t] represents the coefficient matrix at time t. The intercept vector is stacked in the first column; the p coefficient matrices of dimension [M,M] are placed next to it.


Posterior means of error term covariance matrices. This is an array of dimension [M, M, T]. The submatrix [, , t] represents the covariance matrix at time t.

Q.postmean, S.postmean, W.postmean

Posterior means of various covariance matrices.


Draws for the forecast mean vector at various horizons (three-dimensional array, where the first dimension corresponds to system variables, the second to forecast horizons, and the third to MCMC draws). Note: The third dimension will be equal to nrep/thinfac, apart from possible rounding issues.


Draws for the forecast covariance matrix. Design similar to fc.mdraws, except that the first array dimension contains the lower-diagonal elements of the forecast covariance matrix.


Simulated future observations. Design analogous to fc.mdraws.

Beta.draws, H.draws

Matrices of parameter draws, can be used for computing impulse responses later on (see impulse.responses), and accessed via the helper function parameter.draws. These outputs are generated only if save.parameters has been set to TRUE.


Fabian Krueger, based on Matlab code by Dimitris Korobilis (see Koop and Korobilis, 2010). Incorporates the corrigendum by Del Negro and Primiceri (2015), which points to an error in the original MCMC algorithm of Primiceri (2005).


Del Negro, M. and Primicerio, G.E. (2015). ‘Time Varying Structural Vector Autoregressions and Monetary Policy: A Corrigendum’, Review of Economic Studies 82, 1342-1345.

Koop, G. and D. Korobilis (2010): ‘Bayesian Multivariate Time Series Methods for Empirical Macroeconomics’, Foundations and Trends in Econometrics 3, 267-358. Accompanying Matlab code available at

Primiceri, G.E. (2005): ‘Time Varying Structural Vector Autoregressions and Monetary Policy’, Review of Economic Studies 72, 821-852.

See Also

The helper functions predictive.density and predictive.draws provide simple access to the forecast distribution produced by Impulse responses can be computed using impulse.responses. For detailed examples and explanations, see the accompanying pdf file hosted at


## Not run: 

# Load US macro data

# Estimate trivariate BVAR using default settings
bv <-

## End(Not run)

[Package bvarsv version 1.1 Index]