set_prior: Set priors for mfbvar

Description Usage Arguments Details Value See Also Examples

View source: R/interface.R

Description

The function creates an object storing all information needed for estimating a mixed-frequency BVAR. The object includes data as well as details for the model and its priors.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
set_prior(
  Y,
  aggregation = "average",
  prior_Pi_AR1 = 0,
  lambda1 = 0.2,
  lambda2 = 0.5,
  lambda3 = 1,
  lambda4 = 10000,
  block_exo = NULL,
  n_lags,
  n_fcst = 0,
  n_thin = 1,
  n_reps,
  n_burnin = n_reps,
  freq = NULL,
  d = NULL,
  d_fcst = NULL,
  prior_psi_mean = NULL,
  prior_psi_Omega = NULL,
  check_roots = FALSE,
  s = -1000,
  prior_ng = c(0.01, 0.01),
  prior_phi = c(0.9, 0.1),
  prior_sigma2 = c(0.01, 4),
  n_fac = NULL,
  n_cores = 1,
  verbose = FALSE,
  ...
)

update_prior(prior_obj, ...)

Arguments

Y

data input. For monthly-quarterly data, should be a list with components containing regularly spaced time series (that inherit from ts or zooreg). If a component contains a single time series, the component itself must be named. If a component contains multiple time series, each time series must be named. Monthly variables can only contain missing values at the end of the sample, and should precede quarterly variables in the list. Matrices in which quarterly variables are padded with NA and observations stored at the end of each quarter are also accepted, but then the frequency of each variable must be given in the argument freq. Weekly-monthly mixes can be provided using the matrix way, see examples.

aggregation

the aggregation scheme used for relating latent high-frequency series to their low-frequency observations. The default is "average" for averaging within each low-frequency period (e.g., quarterly observations are averages of the constituent monthly observations). The alternative "triangular" can be used for monthly-quarterly mixes, and uses the Mariano-Murasawa triangular set of weights. See details for more information.

prior_Pi_AR1

The prior means for the AR(1) coefficients.

lambda1

The overall tightness.

lambda2

(Only if variance is one of c("diffuse", "fsv") The cross-variable tightness

lambda3

The tightness of the intercept prior variance.

lambda4

(Minnesota only) Prior variance of the intercept.

block_exo

(Only if variance is one of c("diffuse", "fsv")) Vector of indexes/names of variables to be treated as block exogenous

n_lags

The number of lags.

n_fcst

The number of periods to forecast.

n_thin

Store every n_thinth draw

n_reps

The number of replications.

n_burnin

The number of burn-in replications.

freq

(Only used if Y is a matrix) Character vector with elements 'm' (monthly) or 'q' (quarterly) for sampling frequency. Monthly variables must precede all quarterly variables.

d

(Steady state only) Either a matrix with same number of rows as Y and n_determ number of columns containing the deterministic terms or a string "intercept" for requesting an intercept as the only deterministic term.

d_fcst

(Steady state only) The deterministic terms for the forecasting period (not used if d = "intercept").

prior_psi_mean

(Steady state only) Vector of length n_determ*n_vars with the prior means of the steady-state parameters.

prior_psi_Omega

(Steady state only) Matrix of size (n_determ*n_vars) * (n_determ*n_vars) with the prior covariance of the steady-state parameters.#'

check_roots

Logical, if roots of the companion matrix are to be checked to ensure stationarity.

s

(Hierarchical steady state only) scalar giving the tuning parameter for the Metropolis-Hastings proposal for the kurtosis parameter. If s < 0, then adaptive Metropolis-Hastings targeting an acceptance rate of 0.44 is used, where the scaling factor is restricted to the interval [-abs(s), abs(s)]

prior_ng

(Hierarchical steady state only) vector with two elements giving the parameters c(c0, c1) of the hyperprior for the global shrinkage parameter

prior_phi

(Only used with common stochastic volatility) Vector with two elements c(mean, variance) for the AR(1) parameter in the log-volatility regression

prior_sigma2

(Only used with common stochastic volatility) Vector with two elements c(mean, df) for the innovation variance of the log-volatility regression

n_fac

(Only used with factor stochastic volatility) Number of factors to use for the factor stochastic volatility model

n_cores

(Only used with factor stochastic volatility) Number of cores to use for drawing regression parameters in parallel

verbose

Logical, if progress should be printed to the console.

...

(Only used with factor stochastic volatility) Arguments to pass along to fsvsample. See details.

prior_obj

an object of class mfbvar_prior

Details

Some support is provided for single-frequency data sets, where Y contains variables sampled with the same frequency.

The aggregation weights that can be used for aggregation are intra-quarterly averages (aggregation = "average"), where the quarterly observations y_{q,t} are assumed to relate to the underlying monthly series z_{q,,t} through:

y_{q,t} = \frac{1}{3}(z_{q,,t} + z_{q,,t-1} + z_{q,, t-2})

If aggregation = "triangular", then instead

y_{q,t} = \frac{1}{9}(z_{q,,t} + 2z_{q,,t-1} + 3z_{q,, t-2}) + 2z_{q,, t-3}) + z_{q,, t-4})

The latter is typically used when modeling growth rates, and the former when working with log-levels.

If the steady-state prior is to be used, the deterministic matrix needs to be supplied, or a string indicating that the intercept should be the only deterministic term (d = "intercept"). If the latter, d_fcst is automatically set to be intercept only. Otherwise, if forecasts are requested (n_fcst > 0) also d_fcst must be provided. Finally, the prior means of the steady-state parameters must (at the very minimum) also be provided in prior_psi_mean. The steady-state prior involves inverting the lag polynomial. For this reason, draws in which the largest eigenvalue (in absolute value) of the lag polynomial is greater than 1 are discarded and new draws are made if check_roots = TRUE. The maximum number of attempts is 1,000.

For modeling stochastic volatility by the factor stochastic volatility model, the number of factors to use must be supplied. Further arguments can be passed along, but are not included as formal arguments. If the default settings are not overriden, the defaults used are as follows (see fsvsample for descriptions):

The function update_prior can be used to update an existing prior object. See the examples.

Value

An object of class mfbvar_prior that is used as input to estimate_mfbvar.

See Also

estimate_mfbvar, update_prior, interval_to_moments, print.mfbvar_prior, summary.mfbvar_prior, fsvsample

Examples

1
2
3
4
5
6
7
8
9
# Standard list-based way
prior_obj <- set_prior(Y = mf_usa, n_lags = 4, n_reps = 100)
prior_obj <- update_prior(prior_obj, n_fcst = 4)

# Weekly-monthly mix of data, four weeks per month
Y <- matrix(rnorm(400), 100, 4)
Y[setdiff(1:100,seq(4, 100, by = 4)), 4] <- NA
prior_obj <- set_prior(Y = Y, freq = c(rep("w", 3), "m"),
                       n_lags = 4, n_reps = 10)

mfbvar documentation built on Feb. 10, 2021, 5:12 p.m.