Package 'SteadyStateBVAR'

Title: Bayesian Vector Autoregressions with Steady-State Priors
Description: Provides estimation of Bayesian vector autoregression (BVAR) models with steady-state priors via 'Stan', along with functions for unconditional and conditional forecasting, as well as impulse response analysis. For details on the steady-state BVAR model see Villani (2009) <doi:10.1002/jae.1065>.
Authors: Mark Becker [aut, cre, cph]
Maintainer: Mark Becker <[email protected]>
License: GPL (>= 3)
Version: 0.2.0.9000
Built: 2026-10-15 08:02:32 UTC
Source: https://github.com/markjwbecker/steadystatebvar

Help Index


Create a steady-state BVAR model object

Description

Initialises a steady-state bvar object. This is the starting point for all models in SteadyStateBVAR. After creation, pass the object sequentially to setup, priors, and fit to build and estimate the model.

Usage

bvar(data)

Arguments

data

A numeric matrix or time series of data where each column is a variable and each row is a time period.

Details

For a detailed theoretical introduction to the steady-state BVAR model, run the following

vignette("SteadyStateBVAR-intro")

The steady-state BVAR model takes the form

yt=Ψdt+Π1(yt−1−Ψdt−1)+⋯+Πp(yt−p−Ψdt−p)+uty_t = \Psi d_t + \Pi_1(y_{t-1}-\Psi d_{t-1})+\dots+\Pi_p(y_{t-p}-\Psi d_{t-p})+u_t

where yty_t is an kk-dimensional vector of endogenous variables at time tt, and dtd_t is a qq-dimensional vector of deterministic (exogenous) variables at time tt. Here Πℓ\Pi_\ell for ℓ=1,…,p\ell=1,\dots,p is a (k×k)(k \times k) matrix of autoregressive parameters, and Ψ\Psi is a (k×q)(k \times q) matrix of steady-state parameters. Now

E(yt)=μt=Ψdt\mathrm{E}(y_t)=\mu_t=\Psi d_t

is the unconditional mean, or the steady state of the process. Note that the current version of this package only allows for dtd_t to contain either a constant, a constant and a dummy variable, or a constant and a time trend. We may stack the (transposed) Πi\Pi_i matrices in the (kp×k)(kp \times k) matrix β\beta

β=[Π1′⋮Πp′]\beta=\begin{bmatrix}\Pi'_1 \\ \vdots \\\Pi'_p\end{bmatrix}

Then the model can be rewritten as a nonlinear regression (Karlsson, 2013)

yt′=dt′Ψ′+[wt′−qt′(Ip⊗Ψ′)]β+ut′y_t' =d_t'\Psi' + \left[w_t'-q_t'(I_p \otimes \Psi') \right]\beta +u_t'

where wt′=(yt−1′,…,yt−p′)w_t'=(y_{t-1}',\dots,y_{t-p}') is a kpkp-dimensional vector of lagged endogenous variables and qt′=(dt−1′,…,dt−p′)q_t'=(d_{t-1}',\dots,d_{t-p}') is a qpqp-dimensional vector of lagged deterministic (exogenous) variables, IpI_p is the (p×p)(p \times p) identity matrix and ⊗\otimes denotes the Kronecker product. The goal is to estimate the parameters Θ=[βΨΣu]\Theta = \begin{bmatrix} \beta & \Psi & \Sigma_u \end{bmatrix}, and as such priors are needed. Please see priors for more details.

For the innovations to the model, in the case of the homoscedastic (the original) steady-state BVAR, they are ut∼iidNk(0,Σu)u_t \overset{\text{iid}}{\sim} \mathrm{N_k}(0,\Sigma_u). However, with stochastic volatility, there is instead a time-varying covariance matrix ut∼Nk(0,Σu,t)u_t \sim \mathrm{N_k}(0,\Sigma_{u,t}). The innovations then take the form

ut=A−1Λt0.5ϵtϵt∼iidN(0,Ik)\begin{aligned} u_t &= A^{-1} \Lambda^{0.5}_t \epsilon_t \\ \epsilon_t &\overset{\text{iid}}{\sim} \mathrm{N}(0, \mathrm{I}_k)\end{aligned}

where AA is a lower triangular matrix with ones on the diagonal that describes the contemporaneous interaction of the endogenous variables, and

Λt=diag(λ1,t,…,λk,t)\Lambda_t = \mathrm{diag}(\lambda_{1,t},\dots,\lambda_{k,t})

contains the time-varying volatilities. For the AR1 stochastic volatility specification, the log volatilities follow AR(1) processes

ln⁡λi,t=γ0,i+γ1,iln⁡λi,t−1+νi,t, i=1,…,k\ln \lambda_{i,t} = \gamma_{0,i} + \gamma_{1,i} \ln \lambda_{i,t-1} + \nu_{i,t}, \ i=1,\dots,k

where the log volatility AR(1) processes are restricted to the stationary region, i.e. ∣γ1,i∣<1 ∀i|\gamma_{1,i}|<1 \ \forall i. For the RW stochastic volatility specification, the log volatilities follow (driftless) Random Walk processes

γ0,i=0, γ1,i=1 ∀i\gamma_{0,i}=0, \ \gamma_{1,i}=1 \ \forall i

The innovations to the log volatilities follow in the AR(1) case

νt=(ν1,t,…,νk,t)′∼iidN(0,Φ)\nu_{t} = (\nu_{1,t},\dots,\nu_{k,t})'\overset{\text{iid}}{\sim} \mathrm{N}(0, \Phi)

where Φ\Phi is not diagonal and as such the innovations to the log volatilities are allowed to be correlated across variables. For the Random Walk case, Φ\Phi is diagonal with variances ϕi\phi_i for i=1,…,ki=1,\dots,k.

Note that under both stochastic volatility specifications, the time-varying covariance matrix is

Σu,t=A−1Λt(A−1)′\Sigma_{u,t} = A^{-1} \Lambda_t (A^{-1})'

For details on the homoscedastic steady-state BVAR model, see Villani (2009). For details on the Random Walk stochastic volatility steady-state BVAR model, see Clark (2011). See Carriero, Clark, and Marcellino (2024) for the above-mentioned AR(1) stochastic volatility specification applied to a conventional BVAR.

To see examples for each type of steady-state BVAR model, simply run one of the following

  • vignette("Homoscedastic-steady-state-BVAR")

  • vignette("RW-stochastic-volatility-steady-state-BVAR")

  • vignette("AR1-stochastic-volatility-steady-state-BVAR")

Value

A steady-state bvar object.

References

Carriero, A., Clark, T. E., and Marcellino, M. (2024). Capturing macro-economic tail risks with Bayesian vector autoregressions. Journal of Money, Credit and Banking, 56(5), pp. 1099–1127.

Clark, T. E. (2011). Real-time density forecasts from Bayesian vector autoregressions with stochastic volatility. Journal of Business & Economic Statistics, 29(3), pp. 327–341.

Karlsson, S. (2013). Forecasting with Bayesian vector autoregression. In: Elliott, G. and Timmermann, A. (eds), Handbook of Economic Forecasting. Elsevier B.V., Vol. 2, Part B, pp. 791–897.

Villani, M. (2009). Steady-state priors for vector autoregressions. Journal of Applied Econometrics, 24(4), pp. 630–650.

Examples

yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

Conditional forecasts from a fitted steady-state BVAR model

Description

Computes and plots conditional forecasts from a fitted steady-state bvar object. Conditions are imposed on specific variables at specific horizons using Algorithm 3.3.1 from Dieppe, Legrand, and van Roye (2016). Both conditional and unconditional forecasts are plotted for comparison. Please note that for the moment, conditional forecasting is only enabled for the homoscedastic steady-state BVAR, i.e. when SV=FALSE in priors().

Usage

conditional_forecast(
  x,
  conditions,
  pi = 0.95,
  fcst_type = c("mean", "median"),
  growth_rate_idx = NULL,
  plot_idx = NULL
)

Arguments

x

A steady-state bvar object that has been passed through fit.

conditions

A data frame with three columns: var (integer index of the conditioned variable), horizon (integer forecast horizon at which the condition is imposed), and value (numeric, the imposed condition). Note that var and horizon must be integers, as they are used for indexing.

pi

Numeric. The prediction interval width. Default 0.95, i.e. 95% prediction interval.

fcst_type

Character. Whether to use "mean" or "median" as the point forecast. Default "mean".

growth_rate_idx

Integer vector. Indices of variables of which to convert forecasts to annual growth rates 100(ln⁡xt−ln⁡xt−f)100 (\ln x_{t} - \ln x_{t-f}), where ff is the frequency of the data (4 for quarterly, 12 for monthly). Only suitable for variables specified as 100(ln⁡xt−ln⁡xt−1)100 (\ln x_{t} - \ln x_{t-1}), i.e. 100*diff(log(x)). Computed by summing up to ff log first differences. Default is NULL.

plot_idx

Integer vector. Indices of variables to plot. If NULL (default), all variables are plotted. Forecasts are always computed and returned for all variables, regardless of plot_idx.

Details

See Section 5.3 of Dieppe, Legrand, and van Roye (2016) for more details. Please note the limitations of this method, see the detailed discussion in Section 5.4 of Dieppe, Legrand, and van Roye (2016).

Value

Invisibly returns a list with three matrices: forecast, lower, and upper, each of dimension H x k.

References

Dieppe, A., Legrand, R., and van Roye, B. (2016). The BEAR toolbox. Working Paper Series, No. 1934. European Central Bank.

Examples

#homoscedastic with Jeffreys prior
yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p=1, deterministic = "constant")

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   Jeffreys = TRUE,
                   SV = FALSE,
                   SV_type = NULL,
                   SV_priors = NULL)
                   
bvar_obj <- fit(bvar_obj,
                H = 8,
                iter = 200,
                warmup = 50,
                chains = 1,
                cores = 1)
                
conditions <- data.frame(var = rep(2,8),
                         horizon = rep(1:8),
                         value   = rep(1,8))
                         
(cond_fcst <- conditional_forecast(bvar_obj,
                                  conditions,
                                  pi=0.68,
                                  fcst_type = "mean"))

Estimate the steady-state BVAR model using Stan

Description

Estimates the steady-state BVAR model using the No-U-Turn sampler (a variant of Hamiltonian Monte Carlo) via Stan. Also generates draws from the joint predictive distribution. Uses the data, setup, and priors stored in the steady-state bvar object.

Usage

fit(x, H = 1, d_pred = NULL, ...)

Arguments

x

A steady-state bvar object that has been passed through setup and priors.

H

Positive Integer. Forecast horizon. Default is 1.

d_pred

Matrix of size H×qH \times q. Future values of the deterministic variables dtd_t. Default is NULL (d_pred is automatically created). If dtd_t contains only a constant, dt+h=1 ∀ hd_{t+h}=1 \ \forall \ h. If dtd_t contains a constant and a dummy, it is assumed that the dummy (and the constant) stays at its last observed value for all future forecast periods. However, if this is not the intention, the user may supply d_pred themselves. If dtd_t contains a constant and a trend, the trend is extrapolated from its last observed value (i.e. trendT+h=trendT+htrend_{T+h}=trend_{T}+h). Naturally, the constant is again equal to one for all future periods.

...

Additional arguments passed directly to the rstan function sampling

Details

The function selects the appropriate precompiled Stan model based on settings from priors:

  • steady_state_bvar_homoscedastic_jeffreys_prior

  • steady_state_bvar_homoscedastic_inverse_wishart_prior

  • steady_state_bvar_RW_stochastic_volatility

  • steady_state_bvar_AR1_stochastic_volatility

The function estimates the following parameter matrices/vectors (see bvar for details):

  • beta: kp×kkp \times k VAR coefficient matrix

  • Psi: k×qk \times q steady-state parameter matrix

  • Sigma_u: innovation covariance matrix (k×kk \times k for homoscedastic, T×k×kT \times k \times k for stochastic volatility)

  • If Random Walk stochastic volatility:

    • A: k×kk \times k lower triangular matrix with ones on the diagonal that describes the contemporaneous interaction of the endogenous variables

    • phi: kk-dimensional vector of log volatility innovation variances

  • If AR1 stochastic volatility:

    • A: k×kk \times k lower triangular matrix with ones on the diagonal that describes the contemporaneous interaction of the endogenous variables

    • gamma_0: kk-dimensional vector of log volatility intercepts

    • gamma_1: kk-dimensional vector of log volatility slopes

    • Phi: k×kk \times k log volatility innovation covariance matrix

Value

A fitted steady-state bvar object with:

  • x$fit$stan: An object of class stanfit

  • x$fit$posterior_means: List of elementwise posterior mean estimates

  • x$fit$posterior_medians: List of elementwise posterior median estimates

Examples

#homoscedastic with Jeffreys prior, d_t = constant

yt <- matrix(rnorm(20), 10, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p = 1, deterministic = "constant")

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   Jeffreys = TRUE)
                   

bvar_obj <- fit(bvar_obj,
                H = 8,
                iter = 200,
                warmup = 50,
                chains = 1,
                cores = 1)
                
                
#homoscedastic with inverse-Wishart prior, d_t = constant and dummy

yt <- matrix(rnorm(20), 10, 2)

bvar_obj <- bvar(data = yt)

dummy_variable <- c(rep(1,5), rep(0,5))

bvar_obj <- setup(bvar_obj, p = 1,
                  deterministic = "constant_and_dummy",
                  dummy = dummy_variable)
                  
k <- bvar_obj$setup$k
q <- bvar_obj$setup$q

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, k*q),
                   Omega_Psi = diag(0.1, k*q, k*q),
                   Jeffreys = FALSE) #inverse-Wishart


bvar_obj <- fit(bvar_obj,
                H = 8,
                iter = 200,
                warmup = 50,
                chains = 1,
                cores = 1)
 

#RW stochastic volatility

yt <- matrix(rnorm(20), 10, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p=1, deterministic = "constant")

k <- bvar_obj$setup$k
n_free_params_A <- bvar_obj$setup$n_free_params_A

SV_priors_RW <- list(
theta_A              =  rep(0, n_free_params_A),
Omega_A              =  diag(1000, n_free_params_A),
theta_log_lambda_1   =  rep(0, k),
Omega_log_lambda_1   =  diag(1000, k),
alpha_phi            =  rep(5, k),
beta_phi             = (rep(5, k) - 1) * rep(0.1, k)
)

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   SV = TRUE,
                   SV_type = "RW",
                   SV_priors = SV_priors_RW)

bvar_obj <- fit(bvar_obj,
                H = 8,
                iter = 200,
                warmup = 50,
                chains = 1,
                cores = 1,
                control = list(max_treedepth = 12, adapt_delta = 0.85)
                )


#AR1 stochastic volatility

yt <- matrix(rnorm(20), 10, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p=1, deterministic = "constant")

k <- bvar_obj$setup$k
n_free_params_A <- bvar_obj$setup$n_free_params_A

SV_priors_AR1 <- list(
theta_A               =  rep(0, n_free_params_A),
Omega_A               =  diag(1000, n_free_params_A),
theta_gamma_0         =  rep(0.1, k),
Omega_gamma_0         =  diag(1000, k),
theta_gamma_1         =  rep(0.9, k),
Omega_gamma_1         =  diag(10, k),
theta_log_lambda_1    =  rep(0.1, k)/(1-rep(0.9, k)),
Omega_log_lambda_1    =  diag(1000, k),
V_Phi                 = (10 - k - 1) * diag(k),
m_Phi                 =  10
)

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   SV = TRUE,
                   SV_type = "AR1",
                   SV_priors = SV_priors_AR1)

bvar_obj <- fit(bvar_obj,
                H = 8,
                iter = 200,
                warmup = 50,
                chains = 1,
                cores = 1,
                control = list(max_treedepth = 12, adapt_delta = 0.85)
                )

Forecast from a fitted steady-state BVAR model

Description

Computes and plots forecasts from a fitted steady-state bvar object. Draws from the joint predictive distribution are used to construct point forecasts and prediction intervals. Optionally converts monthly or quarterly growth rate forecasts to annual growth rates for variables specified as 100*diff(log(x)). Optionally overlays the posterior steady states.

Usage

forecast(
  x,
  pi = 0.95,
  fcst_type = c("mean", "median"),
  growth_rate_idx = NULL,
  plot_idx = NULL,
  show_all = TRUE,
  ss = TRUE,
  ss_type = c("mean", "median"),
  ss_ci = 0.95
)

Arguments

x

A steady-state bvar object that has been passed through fit.

pi

Numeric. The prediction interval width. Default 0.95, i.e. 95% prediction interval.

fcst_type

Character. Whether to use "mean" or "median" as the point forecast. Default "mean".

growth_rate_idx

Integer vector. Indices of variables of which to convert forecasts to annual growth rates 100(ln⁡xt−ln⁡xt−f)100 (\ln x_{t} - \ln x_{t-f}), where ff is the frequency of the data (4 for quarterly, 12 for monthly). Only suitable for variables specified as 100(ln⁡xt−ln⁡xt−1)100 (\ln x_{t} - \ln x_{t-1}), i.e. 100*diff(log(x)). Computed by summing up to ff log first differences. Default is NULL.

plot_idx

Integer vector. Indices of variables to plot. If NULL (default), all variables are plotted. Forecasts are always computed and returned for all variables, regardless of plot_idx.

show_all

Logical. If TRUE (default), the full history is shown. If FALSE, the last eight years of history are shown.

ss

Logical. If TRUE, overlays the posterior steady state μt=Ψdt\mu_t = \Psi d_t. Default TRUE. For variables in growth_rate_idx, the posterior steady-state is annualized.

ss_type

Character. Whether to use "mean" or "median" of the posterior as the steady-state point estimate. Default "mean".

ss_ci

Numeric. The posterior credible interval width for the steady state. Default 0.95, i.e. 95% credible interval.

Value

Invisibly returns a list with three matrices: forecast, lower, and upper, each of dimension H x k where H is the forecast horizon and k is the number of variables.

Examples

#homoscedastic with Jeffreys prior
yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p=1, deterministic = "constant")

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   Jeffreys = TRUE)
                   
bvar_obj <- fit(bvar_obj,
                H = 8,
                iter = 200,
                warmup = 50,
                chains = 1,
                cores = 1)
                
forecast(bvar_obj,
         fcst_type = "mean",
         pi = 0.90,
         show_all = TRUE,
         ss = TRUE,
         ss_type = "mean",
         ss_ci = 0.95)

Impulse Response Functions for a fitted steady-state BVAR model

Description

Computes and plots impulse response functions (IRFs) from a fitted steady-state bvar object. Supports both orthogonalized (OIRF) and generalized (GIRF) impulse responses, with optional conversion to annual growth rates.

Usage

IRF(
  x,
  H = 20,
  response = NULL,
  impulse = NULL,
  type = c("median", "mean"),
  method = c("OIRF", "GIRF"),
  ci = 0.95,
  t = NULL,
  growth_rate_idx = NULL
)

Arguments

x

A steady-state bvar object that has been passed through fit.

H

Integer. The forecast horizon for the IRF. Default 20.

response

Integer vector. Indices of the response variables to plot. If NULL (default), all responses are plotted.

impulse

Integer vector. Indices of the impulse variables to plot. If NULL (default), all impulses are plotted.

type

Character. Whether to use "median" or "mean" as the point estimate. Default "median".

method

Character. The IRF method: "OIRF" for orthogonalized or "GIRF" for generalized impulse responses. Default "OIRF".

ci

Numeric. The credible interval width. Default 0.95, i.e. 95%.

t

Integer. Time index for the covariance matrix when using stochastic volatility models. If NULL (default), the last time t is used.

growth_rate_idx

Integer vector. Indices of variables for which the impulse response is converted from a quarterly or monthly log first difference to an annual growth rate response, i.e. 100(ln⁡xt−ln⁡xt−f)100 (\ln x_{t} - \ln x_{t-f}), where ff is the frequency of the data (4 for quarterly, 12 for monthly). Only suitable for variables specified as 100(ln⁡xt−ln⁡xt−1)100 (\ln x_{t} - \ln x_{t-1}), i.e. 100*diff(log(x)). Computed by summing up to ff periods of the impulse response. Default is NULL.

Value

Invisibly returns a list with three arrays: the point estimate IRF, lower, and upper credible bounds, each of dimension k x k x (H+1).

Examples

#homoscedastic with Jeffreys prior
yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p=1, deterministic = "constant")

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   Jeffreys = TRUE,
                   SV = FALSE,
                   SV_type = NULL,
                   SV_priors = NULL)
                   
bvar_obj <- fit(bvar_obj,
                H = 8,
                iter = 200,
                warmup = 50,
                chains = 1,
                cores = 1)
                
IRF(bvar_obj)

Koop and Korobilis (2010) dataset

Description

Quarterly US macroeconomic data (1953Q1-2006Q3) from Koop and Korobilis (2010)

Usage

KoopKorobilis2010

Format

KoopKorobilis2010

A multivariate time series object with 215 rows and 3 columns:

delta pi

inflation rate (annual percentage change in a chain-weighted GDP price index)

u

unemployment rate (seasonally adjusted civilian unemployment rate, all civilian workers aged 16 years or older)

r

interest rate (yield on the three-month Treasury bill rate)

Source

Koop, G. and Korobilis, D. (2010). Bayesian multivariate time series methods for empirical macroeconomics. Foundations and Trends in Econometrics, 3(4), pp. 267-358.


Prior Probability Interval for a Normal Distribution

Description

Calculates the mean and variance of a normal prior probability interval. Given a lower and upper bound of a prior probability interval this function recovers the implied normal prior parameters. Useful for specifying informative priors on the steady-state parameters (elements of Ψ\Psi).

Usage

ppi(l, u, interval = 0.95, annualized_growthrate = FALSE, freq = NULL)

Arguments

l

Numeric. The lower bound of the prior probability interval.

u

Numeric. The upper bound of the prior probability interval.

interval

Numeric. The prior probability mass within the interval. Default 0.95, i.e. 95%.

annualized_growthrate

Logical. If TRUE, treats l and u as bounds of the annualized steady-state growth rate and calculates the implied mean and variance on the corresponding quarterly/monthly scale. Useful if you are working with a variable specified as 100*diff(log(x)). Default FALSE.

freq

Integer. The data frequency (e.g. 4 for quarterly, 12 for monthly). Only used when annualized_growthrate = TRUE. Default NULL.

Details

Consider a CPI variable CPI <- data$CPI, observed at quarterly frequency. In the model, quarter-on-quarter inflation is used x <- 100*diff(log(CPI)). Suppose the prior belief is that annualized steady-state inflation lies between 1.7 and 2.3 with 95% probability (mean 2). On the quarterly scale used by x, this corresponds to a 95% interval of 0.425 to 0.575 (mean 0.5). Since it is typically more natural to elicit a prior on the annualized scale, the annualized_growthrate argument performs this conversion. See vignette("Homoscedastic-steady-state-BVAR") for usage in practice.

Value

A list with two elements: mean and var, giving the mean and variance of the implied normal distribution.

Examples

ppi(l = 1.7, u = 2.3, interval = 0.95)
ppi(l = 1.7, u = 2.3, interval = 0.95, annualized_growthrate = TRUE, freq = 4)

Specify priors for the steady-state BVAR model

Description

This function prepares the priors. The Minnesota prior is used for the autoregressive parameters, and is determined by the overall tightness, cross-equation tightness, and the lag decay rate. For the steady-state parameters, a normal prior is used. Regarding the covariance matrix of the reduced-form innovations, for the homoscedastic model, the user can choose between Jeffreys prior or an uninformative inverse-Wishart prior. The user may also choose a stochastic volatility specification for the innovations, where the covariance matrix varies over time.

Usage

priors(
  x,
  lambda_1 = 0.2,
  lambda_2 = 0.5,
  lambda_3 = 1,
  first_own_lag_prior_mean = NULL,
  theta_Psi = NULL,
  Omega_Psi = NULL,
  Jeffreys = TRUE,
  SV = FALSE,
  SV_type = NULL,
  SV_priors = NULL
)

Arguments

x

A steady-state bvar object that has been passed through setup.

lambda_1

Numeric. Overall tightness of the Minnesota prior. Default 0.2.

lambda_2

Numeric. Cross-equation tightness of the Minnesota prior. Default 0.5.

lambda_3

Numeric. Lag decay rate of the Minnesota prior. Default 1.

first_own_lag_prior_mean

Numeric vector of length k. Prior means for the first own lags of the variables. If NULL (default), a zero vector is used.

theta_Psi

Numeric vector. Prior mean vector for vec(Ψ)\text{vec}(\Psi), i.e. the steady-state parameters. If NULL (default), the OLS estimates are used.

Omega_Psi

Numeric matrix. Prior covariance matrix for vec(Ψ)\text{vec}(\Psi), i.e. the steady-state parameters. Assumed to be diagonal. If NULL (default), the identity matrix is used.

Jeffreys

Logical. If TRUE (default), uses Jeffreys prior for the innovation covariance matrix. If FALSE, uses an uninformative inverse-Wishart prior. Only considered if SV=FALSE.

SV

Logical. If TRUE, enables stochastic volatility specification. Default FALSE.

SV_type

Character. Type of stochastic volatility model. Must be either "RW" or "AR1". Required if SV = TRUE.

SV_priors

List. User-supplied stochastic volatility priors. Required when SV = TRUE. The list must contain the following named elements depending on SV_type:

  • For "RW": theta_A, Omega_A, theta_log_lambda_1, Omega_log_lambda_1, alpha_phi, beta_phi.

  • For "AR1": theta_A, Omega_A, theta_gamma_0, Omega_gamma_0, theta_gamma_1, Omega_gamma_1, theta_log_lambda_1, Omega_log_lambda_1, V_Phi, m_Phi.

Details

The goal is to estimate the parameters Θ=[βΨΣu]\Theta = \begin{bmatrix} \beta & \Psi & \Sigma_u \end{bmatrix}, and as such priors are needed. Following Villani (2009), prior independence between β,Ψ\beta, \Psi and Σu\Sigma_u is assumed. For β\beta, which contains the autoregressive parameters, the Minnesota prior is used

vec(β)∼Nkpk(θβ,Ωβ)\mathrm{vec}(\beta) \sim \mathrm{N}_{kpk} (\theta_\beta,\Omega_\beta)

The prior means (the elements of θβ\theta_\beta) are specified according to

E(Πℓ(i,j))={κif ℓ=1 and i=j0otherwiseκ={κlevelsif variable i is in levelsκΔif variable i is differenced\begin{aligned} \mathrm{E}\left(\Pi_{\ell}^{(i,j)}\right)&= \begin{cases}\kappa & \text{if } \ell = 1 \ \text{and} \ i = j \\0 & \text{otherwise}\end{cases}\\ \kappa&=\begin{cases}\kappa^{levels} & \text{if } \text{variable} \ i \ \text{is in levels} \\ \kappa^{\Delta} & \text{if } \text{variable} \ i \ \text{is differenced} \end{cases}\\ \end{aligned}

Here, the autoregressive coefficient Πℓ(i,j)\Pi_{\ell}^{(i,j)} is element (i,j)\left(i,j\right) of Πℓ\Pi_{\ell} for ℓ=1,…,p\ell=1,\dots,p. As such, the Minnesota prior sets all prior means for the elements in β\beta to 00, except for the elements that relate to the first own lags of the variables, which are set to κ\kappa. If variable ii is in levels (e.g. nominal interest rate), then κ=κlevels\kappa=\kappa^{levels}, and typical choices for κlevels\kappa^{levels} are 11 or 0.90.9. Evaluating the equations at their prior means, equation ii becomes a random walk if κlevels=1\kappa^{levels}=1 and a persistent stationary AR(1) process if κlevels=0.9\kappa^{levels}=0.9. Since the steady state only exists if the process is stationary, 0.90.9 is recommended for the steady-state BVAR. If variable ii is differenced (e.g. GDP growth), then κ=κΔ\kappa=\kappa^{\Delta}, and the most common choice for κΔ\kappa^{\Delta} is 00, i.e. equation ii becomes (when evaluating it at its prior means) a random walk expressed in first differences (a white noise process). If a differenced variable still shows some degree of persistence (can be examined with an ACF plot), a suitable value for κΔ\kappa^{\Delta} can be (for example) 0.60.6 instead of 00. Moving on to the prior variances, Ωβ\Omega_\beta is a diagonal matrix containing the prior variances for the elements in β\beta. They are specified as

Var(Πℓ(i,j))={(λ1ℓλ3)2if i=j(λ1λ2σiℓλ3σj)2if i≠j\mathrm{Var}\left(\Pi_{\ell}^{(i,j)}\right)= \begin{cases}\left(\frac{\lambda_1}{\ell^{\lambda_3}}\right)^2 & \text{if } i = j \\ \left(\frac{\lambda_1 \lambda_2\sigma_i}{\ell^{\lambda_3}\sigma_j}\right)^2& \text{if } i \neq j \end{cases}

Here λ1\lambda_1, λ2\lambda_2, and λ3\lambda_3 are scalar hyperparameters known as the overall tightness, the cross-equation tightness and the lag decay rate. Furthermore, σi2\sigma_i^2 is the (i,i)(i,i):th element of Σu\Sigma_u, which is unknown and therefore needs to be replaced with an estimate. In this package, it is replaced by the least squares residual variance from a univariate autoregression for variable ii with pp lags (including the constant and dummy/trend variable if applicable). Moving on to Ψ\Psi, the steady-state parameter matrix, the (steady-state) prior is

vec(Ψ)∼Nkq(θΨ,ΩΨ)\mathrm{vec}(\Psi) \sim \mathrm{N}_{kq}(\theta_\Psi,\Omega_\Psi)

This is the core of the steady-state BVAR model. In θΨ\theta_\Psi, one specifies the prior beliefs about the location of the steady state, and in ΩΨ\Omega_\Psi, which is assumed to be a diagonal matrix, one specifies the degree of certainty in those prior beliefs. Too see how to specify steady-state priors in practice, please see the package vignettes. The prior for Σu\Sigma_u is either the usual non-informative Jeffreys prior

p(Σu)∝∣Σu∣−(k+1)/2p(\Sigma_u) \propto\left|\Sigma_u \right|^{-(k+1)/2}

or a proper uninformative inverse-Wishart prior

Σu∼IW(V,m)\Sigma_u \sim \mathrm{IW}(V,m)

where VV is the scale matrix and mm is the number of degrees of freedom. An uninformative prior is specified by setting V=(m−k−1)Σ^uV=(m-k-1)\hat{\Sigma}_u where Σ^u\hat{\Sigma}_u is the least squares estimate from the VAR(pp) (including the constant and dummy/trend variable if applicable), and m=k+2m=k+2. However, if we opt to use stochastic volatility, the innovation covariance matrix is time-varying Σu,t\Sigma_{u,t}, instead of constant Σu\Sigma_{u}. Therefore, stochastic volatility priors are needed. See bvar for more details on the stochastic volatility specifications. Please note that λ\lambda below (volatilities) has nothing to do with the λ\lambda from the Minnesota prior (hyperparameters). Now, for the Random Walk ("RW") stochastic volatility specification, the following priors are available

a∼N(θA,ΩA)ln⁡λ1∼N(θln⁡λ1,Ωln⁡λ1)ϕi∼IG(αϕi,βϕi)\begin{aligned}a &\sim \mathrm{N}(\theta_A, \Omega_A) \\ \ln \lambda_{1} &\sim \mathrm{N}(\theta_{\ln \lambda_{1}}, \Omega_{\ln \lambda_{1}}) \\ \phi_i &\sim \mathrm{IG}(\alpha_{\phi_i},\beta_{\phi_i})\end{aligned}

Here aa is a k(k−1)/2k(k-1)/2-dimensional vector that collects the free parameters in AA in row-major order, and ln⁡λ1\ln \lambda_1 is a kk-dimensional vector containing the time t=1t=1 values (initial conditions) of ln⁡λt\ln \lambda_{t}. We assume that ΩA\Omega_A and Ωln⁡λ1\Omega_{\ln \lambda_{1}} are diagonal matrices. Furthermore, ϕi\phi_i for i=1,…,ki=1,\dots,k are the log volatility innovation variances. For the AR(1) ("AR1") stochastic volatility specification, the following priors are available

a∼N(θA,ΩA)γ0∼N(θγ0,Ωγ0)γ1∼N(θγ1,Ωγ1) I(∣γ1,i∣<1)ln⁡λ1∼N(θln⁡λ1,Ωln⁡λ1)Φ∼IW(VΦ,mΦ)\begin{aligned}a &\sim \mathrm{N}(\theta_A, \Omega_A) \\ \gamma_{0} &\sim \mathrm{N}(\theta_{\gamma_0}, \Omega_{\gamma_0}) \\ \gamma_{1} &\sim \mathrm{N}(\theta_{\gamma_1}, \Omega_{\gamma_1}) \ I(|\gamma_{1,i}| < 1)\\ \ln \lambda_{1} &\sim \mathrm{N}(\theta_{\ln \lambda_{1}}, \Omega_{\ln \lambda_{1}}) \\ \Phi &\sim \mathrm{IW}(V_{\Phi},m_{\Phi})\end{aligned}

Here aa is again the k(k−1)/2k(k-1)/2-dimensional vector that collects the free parameters in AA in row-major order, and ln⁡λ1\ln \lambda_1 is a kk-dimensional vector containing the time t=1t=1 values (initial conditions) of ln⁡λt\ln \lambda_{t}. Furthermore, γ0\gamma_{0} is a kk-dimensional vector of log volatility intercepts, γ1\gamma_{1} is a kk-dimensional vector of log volatility slopes, and Φ\Phi is the k×kk \times k log volatility innovation covariance matrix. We assume that ΩA\Omega_A, Ωγ0\Omega_{\gamma_0}, Ωγ1\Omega_{\gamma_1}, and Ωln⁡λ1\Omega_{\ln \lambda_{1}} are diagonal matrices. Note that the prior for γ1\gamma_1 is truncated normal.

For details on the homoscedastic steady-state BVAR model, see Villani (2009). For details on the Random Walk stochastic volatility steady-state BVAR model, see Clark (2011). See Carriero, Clark, and Marcellino (2024) for the AR(1) stochastic volatility specification applied to a conventional BVAR.

To see examples of how to specify the priors, simply view the relevant vignette

  • vignette("Homoscedastic-steady-state-BVAR")

  • vignette("RW-stochastic-volatility-steady-state-BVAR")

  • vignette("AR1-stochastic-volatility-steady-state-BVAR")

Value

The steady-state bvar object with an appended priors list containing:

theta_beta

Prior mean vector for vec(β)\text{vec}(\beta), i.e. the autoregressive parameters, constructed with the Minnesota prior

Omega_beta

Prior covariance matrix for vec(β)\text{vec}(\beta), i.e. the autoregressive parameters, constructed with the Minnesota prior

theta_Psi

Prior mean vector for vec(Ψ)\text{vec}(\Psi), i.e. the steady-state parameters

Omega_Psi

Prior covariance matrix for vec(Ψ)\text{vec}(\Psi), i.e. the steady-state parameters

Jeffreys

Indicator for Jeffreys prior usage

Sigma_AR

Residual variance estimates from univariate AR fits, which are used by the Minnesota prior

m

Inverse-Wishart prior degrees of freedom (if Jeffreys = FALSE and SV = FALSE)

V

Inverse-Wishart prior scale matrix (if Jeffreys = FALSE and SV = FALSE)

SV

Logical indicator for stochastic volatility specification

SV_type

Stochastic volatility specification type

SV_priors

User-supplied SV prior list (if SV = TRUE)

References

Carriero, A., Clark, T. E., and Marcellino, M. (2024). Capturing macro-economic tail risks with Bayesian vector autoregressions. Journal of Money, Credit and Banking, 56(5), pp. 1099–1127.

Clark, T. E. (2011). Real-time density forecasts from Bayesian vector autoregressions with stochastic volatility. Journal of Business & Economic Statistics, 29(3), pp. 327–341.

Villani, M. (2009). Steady-state priors for vector autoregressions. Journal of Applied Econometrics, 24(4), pp. 630–650.

Examples

#homoscedastic with Jeffreys prior
yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p=1)

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   Jeffreys = TRUE,
                   SV = FALSE,
                   SV_type = NULL,
                   SV_priors = NULL)
                   
#RW stochastic volatility
yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p=1)

k <- bvar_obj$setup$k
n_free_params_A <- bvar_obj$setup$n_free_params_A

SV_priors_RW <- list(
theta_A              =  rep(0, n_free_params_A),
Omega_A              =  diag(1000, n_free_params_A),
theta_log_lambda_1   =  rep(0, k),
Omega_log_lambda_1   =  diag(1000, k),
alpha_phi            =  rep(5, k),
beta_phi             = (rep(5, k) - 1) * rep(0.1, k)
)

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   SV = TRUE,
                   SV_type = "RW",
                   SV_priors = SV_priors_RW)
                   
#AR1 stochastic volatility
yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p=1)

k <- bvar_obj$setup$k
n_free_params_A <- bvar_obj$setup$n_free_params_A

SV_priors_AR1 <- list(
theta_A               =  rep(0, n_free_params_A),
Omega_A               =  diag(1000, n_free_params_A),
theta_gamma_0         =  rep(0.1, k),
Omega_gamma_0         =  diag(1000, k),
theta_gamma_1         =  rep(0.9, k),
Omega_gamma_1         =  diag(10, k),
theta_log_lambda_1    =  rep(0.1, k)/(1-rep(0.9, k)),
Omega_log_lambda_1    =  diag(1000, k),
V_Phi                 = (10 - k - 1) * diag(k),
m_Phi                 =  10
)

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   SV = TRUE,
                   SV_type = "AR1",
                   SV_priors = SV_priors_AR1)

Restrict VAR coefficients to zero

Description

Applies zero restrictions to the VAR coefficient matrix β\beta by setting the corresponding prior variances in Omega_beta to a value near zero (prior means are zero by default in the Minnesota prior).

Usage

restrict_beta(x, restriction_matrix)

Arguments

x

A steady-state bvar object that has been passed through priors.

restriction_matrix

A numeric matrix of dimension k*p x k where entries of 0 indicate coefficients to be restricted to zero and entries of 1 indicate unrestricted coefficients.

Details

The steady-state BVAR model takes the form

yt=Ψdt+Π1(yt−1−Ψdt−1)+⋯+Πp(yt−p−Ψdt−p)+uty_t = \Psi d_t + \Pi_1(y_{t-1}-\Psi d_{t-1})+\dots+\Pi_p(y_{t-p}-\Psi d_{t-p})+u_t

where yty_t is an kk-dimensional vector of endogenous variables at time tt, and dtd_t is a qq-dimensional vector of deterministic (exogenous) variables at time tt. Here Πℓ\Pi_\ell for ℓ=1,…,p\ell=1,\dots,p is a (k×k)(k \times k) matrix of autoregressive parameters, and Ψ\Psi is a (k×q)(k \times q) matrix of steady-state parameters. One can stack the (transposed) Πi\Pi_i matrices in the (kp×k)(kp \times k) matrix β\beta

β=[Π1′⋮Πp′]\beta=\begin{bmatrix}\Pi'_1 \\ \vdots \\\Pi'_p\end{bmatrix}

This function puts zero restrictions on the autoregressive parameters/coefficients, i.e the elements of β\beta.

Value

The steady-state bvar object with the restriction matrix stored in setup and the prior covariance matrix Omega_beta updated accordingly.

Examples

yt <- matrix(rnorm(50), 25, 2)
colnames(yt) <- c("y1", "y2")

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p=2)

bvar_obj <- priors(bvar_obj,
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2))
                   
p <- bvar_obj$setup$p
k <- bvar_obj$setup$k

restriction_matrix <- matrix(1,k*p,k)

#restrict beta so y2 does not granger-cause y1

restriction_matrix[2, 1] <- 0
restriction_matrix[4, 1] <- 0

bvar_obj <- restrict_beta(bvar_obj, restriction_matrix)

Set up the steady-state BVAR model

Description

Prepares the components needed for prior specification and estimation. Also computes OLS estimates.

Usage

setup(
  x,
  p = 1,
  deterministic = c("constant", "constant_and_dummy", "constant_and_trend"),
  dummy = NULL
)

Arguments

x

A steady-state bvar object created by bvar.

p

Integer. The lag order of the VAR. Default 1.

deterministic

Character. The deterministic components to include in dtd_t. One of "constant" (default), "constant_and_dummy", or "constant_and_trend".

dummy

Numeric vector of a dummy variable. Only used when deterministic = "constant_and_dummy". Default NULL.

Value

The steady-state bvar object with a setup list containing the required components for prior specification and estimation, and also the OLS estimates.

Examples

yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj)

Plot steady-state priors

Description

Produces time series plots of the data along with the implied prior for the steady state μt=Ψdt\mu_t = \Psi d_t.

Usage

steady_state_priors_plot(
  x,
  interval = 0.95,
  growth_rate_idx = NULL,
  plot_idx = NULL
)

Arguments

x

A steady-state bvar object that has been passed through priors.

interval

Numeric. The prior interval width. Default 0.95, i.e. a 95% prior interval for the steady state.

growth_rate_idx

Integer vector. Indices of variables specified as 100(ln⁡xt−ln⁡xt−1)100 (\ln x_{t} - \ln x_{t-1}), i.e. 100*diff(log(x)), for which the historical series is converted to year-over-year (annual) growth scale 100(ln⁡xt−ln⁡xt−f)100 (\ln x_{t} - \ln x_{t-f}) and the steady-state prior is converted to the annualized (not annual) growth scale f100(ln⁡xt−ln⁡xt−1)f100(\ln x_{t} - \ln x_{t-1}) where ff = frequency. Default is NULL.

plot_idx

Integer vector. Indices of variables to plot. If NULL (default), all variables are plotted.

Details

The implied prior for the steady state μt=Ψdt\mu_t = \Psi d_t is based on the prior for Ψ\Psi

vec(Ψ)∼N(θΨ,ΩΨ)\mathrm{vec}(\Psi) \sim \mathrm{N}(\theta_\Psi, \Omega_\Psi)

which is specified in priors. Note that it is assumed that ΩΨ\Omega_\Psi is diagonal.

Value

Invisibly returns a list with three matrices, lower, mean, and upper, each of dimension T x k giving the steady-state prior bounds and mean over the historical sample. For growth_rate_idx columns, these are on the annualized scale.

Examples

yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p = 1, deterministic = "constant")

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1, 2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   Jeffreys = TRUE)

steady_state_priors_plot(bvar_obj)

Plot stochastic volatility estimates and forecasts

Description

Produces time series plots of posterior stochastic volatility estimates over the estimation sample together with predictive paths over the forecast horizon for a fitted steady-state bvar object with stochastic volatility.

Usage

stochastic_volatility_plot(
  x,
  ci = 0.95,
  vol = "log_lambda",
  stat = "mean",
  plot_idx = NULL,
  xlim = NULL,
  ylim = NULL
)

Arguments

x

A steady-state bvar object that has been passed through fit with stochastic volatility enabled.

ci

Numeric. Interval level. Default is 0.95.

vol

Character. Volatility representation: "log_lambda" (default) or "sd".

stat

Character. Posterior summary statistic to use as point estimate: "mean" (default) or "median".

plot_idx

Integer vector. Indices of variables to plot. If NULL (default), all variables are plotted.

xlim

Numeric vector of length 2. Optional x-axis limits.

ylim

Numeric vector of length 2. Optional y-axis limits.

Details

The function supports two volatility representations:

  • "log_lambda": log volatilities

  • "sd": implied standard deviations of the reduced-form innovations utu_{t}

For each selected variable, the function plots the posterior point estimate path and credible bands over the estimation sample, and the predictive point estimate path and prediction intervals over the forecast horizon.

Value

An invisible list with:

  • estimated: List of posterior summaries for the estimation sample:

    • point: T×kT \times k matrix of posterior point estimates (mean or median depending on stat)

    • lower: T×kT \times k matrix of lower credible bounds

    • upper: T×kT \times k matrix of upper credible bounds

  • predicted: List of posterior summaries for the forecast horizon:

    • point: (T+H)×k(T+H) \times k matrix of predictive point estimates (mean or median depending on stat)

    • lower: (T+H)×k(T+H) \times k matrix of lower bound of prediction interval

    • upper: (T+H)×k(T+H) \times k matrix of upper bound of prediction interval

Examples

yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p = 1, deterministic = "constant")

k <- bvar_obj$setup$k
n_free_params_A <- bvar_obj$setup$n_free_params_A

SV_priors_RW <- list(
theta_A              =  rep(0, n_free_params_A),
Omega_A              =  diag(1000, n_free_params_A),
theta_log_lambda_1   =  rep(0, k),
Omega_log_lambda_1   =  diag(1000, k),
alpha_phi            =  rep(5, k),
beta_phi             = (rep(5, k) - 1) * rep(0.1, k)
)

bvar_obj <- priors(bvar_obj,
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   SV = TRUE,
                   SV_type = "RW",
                   SV_priors = SV_priors_RW)

bvar_obj <- fit(bvar_obj,
                H = 8,
                iter = 200,
                warmup = 50,
                chains = 1,
                cores = 1,
                verbose = FALSE)

stochastic_volatility_plot(bvar_obj, ci = 0.95)

Summarize a fitted steady-state BVAR model

Description

Computes and prints elementwise posterior summaries from a fitted steady-state bvar object. The printed output depends on whether the model is homoscedastic or includes stochastic volatility (RW or AR1 specification).

Usage

## S3 method for class 'bvar'
summary(object, pars = NULL, stat = "mean", t = NULL, ...)

Arguments

object

A steady-state bvar object that has been passed through fit.

pars

Character vector of parameter names to include. If NULL (default), all available parameters are displayed.

stat

Character. Posterior summary statistic to display: "mean" (default) or "median".

t

Integer. Time index for the innovation covariance matrix if stochastic volatility was estimated. If NULL, the latest available t is used.

...

Additional arguments (currently unused).

Details

The function summarizes, by calculating elementwise posterior means/medians, the following estimated parameter matrices/vectors:

  • beta: kp×kkp \times k VAR coefficient matrix

  • Psi: k×qk \times q steady-state parameter matrix

  • Sigma_u: innovation covariance matrix (k×kk \times k for homoscedastic, T×k×kT \times k \times k for stochastic volatility)

  • If Random Walk stochastic volatility:

    • A: k×kk \times k lower triangular matrix with ones on the diagonal that describes the contemporaneous interaction of the endogenous variables

    • phi: kk-dimensional vector of log volatility innovation variances

  • If AR1 stochastic volatility:

    • A: k×kk \times k lower triangular matrix with ones on the diagonal that describes the contemporaneous interaction of the endogenous variables

    • gamma_0: kk-dimensional vector of log volatility intercepts

    • gamma_1: kk-dimensional vector of log volatility slopes

    • Phi: k×kk \times k log volatility innovation covariance matrix

Value

Returns the input object invisibly.

Examples

yt <- matrix(rnorm(20), 10, 2)
bvar_obj <- bvar(data = yt)
bvar_obj <- setup(bvar_obj, p = 1, deterministic = "constant")
bvar_obj <- priors(bvar_obj,
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2))

bvar_obj <- fit(bvar_obj,
                H = 1,
                iter = 100,
                warmup = 50,
                chains = 1,
                cores = 1)

summary(bvar_obj)

Villani (2009) dataset

Description

Swedish macroeconomic data (1980Q1–2005Q4) from Section 4.1 in Villani (2009)

Usage

Villani2009

Format

Villani2009

A multivariate time series object with 104 rows and 7 columns:

delta y_f

foreign GDP growth

pi_f

foreign CPI inflation

i_f

foreign 3-month interest rate

delta y

domestic GDP growth

pi

domestic CPI inflation

i

domestic 3-month interest rate

q

level of the real exchange rate defined as q=s+pf−pq = s + p_f - p, where pfp_f and pp are the foreign and domestic CPI levels in logs and ss is the log of the trade-weighted nominal exchange rate

Source

Villani, M. (2009). Steady-state priors for vector autoregressions. Journal of Applied Econometrics, 24(4), pp. 630-650.