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.
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, ...)
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.
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.
The prior means for the AR(1) coefficients.
The overall tightness.
(Only if variance
is one of c("diffuse", "fsv")
The cross-variable tightness
The tightness of the intercept prior variance.
(Minnesota only) Prior variance of the intercept.
(Only if variance
is one of c("diffuse", "fsv")
) Vector of indexes/names of variables to be treated as block exogenous
The number of lags.
The number of periods to forecast.
Store every n_thin
th draw
The number of replications.
The number of burn-in replications.
(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.
(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.
(Steady state only) The deterministic terms for the forecasting period (not used if d = "intercept"
).
(Steady state only) Vector of length n_determ*n_vars
with the prior means of the steady-state parameters.
(Steady state only) Matrix of size (n_determ*n_vars) * (n_determ*n_vars)
with the prior covariance of the steady-state parameters.#'
Logical, if roots of the companion matrix are to be checked to ensure stationarity.
(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)]
(Hierarchical steady state only) vector with two elements giving the parameters c(c0, c1)
of the hyperprior for the global shrinkage parameter
(Only used with common stochastic volatility) Vector with two elements c(mean, variance)
for the AR(1) parameter in the log-volatility regression
(Only used with common stochastic volatility) Vector with two elements c(mean, df)
for the innovation variance of the log-volatility regression
(Only used with factor stochastic volatility) Number of factors to use for the factor stochastic volatility model
(Only used with factor stochastic volatility) Number of cores to use for drawing regression parameters in parallel
Logical, if progress should be printed to the console.
(Only used with factor stochastic volatility) Arguments to pass along to fsvsample
. See details.
an object of class mfbvar_prior
An object of class mfbvar_prior
that is used as input to estimate_mfbvar
.
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):
priormu
= c(0, 10)
priorphiidi
= c(10, 3)
priorphifac
= c(10, 3)
priorsigmaidi
= 1
priorsigmafac
= 1
priorfacload
= 1
restrict
= "none"
The function update_prior
can be used to update an existing prior object. See the examples.
estimate_mfbvar
, update_prior
, interval_to_moments
, print.mfbvar_prior
, summary.mfbvar_prior
, fsvsample
# NOT RUN {
# 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)
# }
Run the code above in your browser using DataLab