View source: R/add_priors.gvarsubmodels.R
add_priors.gvarsubmodels | R Documentation |
Adds prior specifications to a list of country models, which was produced by
the function create_models
.
## S3 method for class 'gvarsubmodels'
add_priors(
object,
...,
coef = list(v_i = 1, v_i_det = 0.1, shape = 3, rate = 1e-04, rate_det = 0.01),
sigma = list(df = "k", scale = 1, mu = 0, v_i = 0.01, hinit = 0.05, constant = 1e-04),
ssvs = NULL,
bvs = NULL
)
object |
a named list, usually, the output of a call to |
... |
further arguments passed to or from other methods. |
coef |
a named list of prior specifications for the coefficients of the country-specific
models. For the default specification all prior means are set to zero and the diagonal elements of
the inverse prior variance-covariance matrix are set to 1 for coefficients corresponding to non-deterministic
terms. For deterministic coefficients the prior variances are set to 10 via |
sigma |
a named list of prior specifications for the error variance-covariance matrix of the country models. For the default specification of an inverse Wishart distribution the prior degrees of freedom are set to the number of endogenous variables and the prior variances to 1. See 'Details'. |
ssvs |
a named list of prior specifications for the SSVS algorithm. See 'Details'. |
bvs |
a named list of prior specifications for the BVS algorithm. See 'Details'. |
The argument coef
can contain the following elements
v_i
a numeric specifying the prior precision of the coefficients. Default is 1.
v_i_det
a numeric specifying the prior precision of coefficients corresponding to deterministic terms. Default is 0.1.
coint_var
a logical specifying whether the prior mean of the first own lag of an
endogenous variable in a VAR model should be set to 1. Default is FALSE
.
const
a numeric or character specifying the prior mean of coefficients, which correspond
to the intercept. If a numeric is provided, all prior means are set to this value.
If const = "mean"
, the means of the series of endogenous variables are used as prior means.
If const = "first"
, the first values of the series of endogenous variables are used as prior means.
minnesota
a list of length 4 containing parameters for the calculation of
the Minnesota prior, where the element names are kappa0
, kappa1
, kappa2
and kappa3
.
For the endogenous variable i
the prior variance of the l
th
lag of regressor j
is obtained as
\frac{\kappa_{0}}{l^2} \textrm{ for own lags of endogenous variables,}
\frac{\kappa_{0} \kappa_{1}}{l^2} \frac{\sigma_{i}^2}{\sigma_{j}^2} \textrm{ for endogenous variables other than own lags,}
\frac{\kappa_{0} \kappa_{2}}{(1 + l)^2} \frac{\sigma_{i}^2}{\sigma_{j}^2} \textrm{ for foreign and global exogenous variables,}
\kappa_{0} \kappa_{3} \sigma_{i}^2 \textrm{ for deterministic terms,}
where \sigma_{i}
is the residual standard deviation of variable i
of an unrestricted
LS estimate. For exogenous variables \sigma_{i}
is the sample standard deviation.
If kappa2 = NULL
, \kappa_{0} \kappa_{3} \sigma_{i}^2
will be used for foreign
and global exogenous variables instead.
max_var
a numeric specifying the maximum prior variance that is allowed for non-deterministic coefficients.
shape
an integer specifying the prior degrees of freedom of the error term of the state equation. Default is 3.
rate
a numeric specifying the prior error variance of the state equation. Default is 0.0001.
rate_det
a numeric specifying the prior error variance of the state equation corresponding to deterministic terms. Default is 0.0001.
If minnesota
is specified, v_i
and v_i_det
are ignored.
Argument sigma
can contain the following elements:
df
an integer or character specifying the prior degrees of freedom of the error term. Only
used, if the prior is inverse Wishart.
Default is "k"
, which indicates the amount of endogenous variables in the respective model.
"k + 3"
can be used to set the prior to the amount of endogenous variables plus 3. If an integer
is provided, the degrees of freedom are set to this value in all models.
scale
a numeric specifying the prior error variance of endogenous variables. Default is 1.
shape
a numeric or character specifying the prior shape parameter of the error term. Only
used, if the prior is inverse gamma or if time varying volatilities are estimated.
For models with constant volatility the default is "k"
, which indicates the amount of endogenous
variables in the respective country model. "k + 3"
can be used to set the prior to the amount of
endogenous variables plus 3. If a numeric is provided, the shape parameters are set to this value in all
models. For models with stochastic volatility this prior refers to the error variance of the state
equation.
rate
a numeric specifying the prior rate parameter of the error term. Only used, if the prior is inverse gamma or if time varying volatilities are estimated. For models with stochastic volatility this prior refers to the error variance of the state equation.
mu
numeric of the prior mean of the initial state of the log-volatilities. Only used for models with time varying volatility.
v_i
numeric of the prior precision of the initial state of the log-volatilities. Only used for models with time varying volatility.
sigma_h
numeric of the initial draw for the variance of the log-volatilities. Only used for models with time varying volatility.
constant
numeric of the constant, which is added before taking the log of the squared errors. Only used for models with time varying volatility.
covar
logical indicating whether error covariances should be estimated. Only used
in combination with an inverse gamma prior or stochastic volatility, for which shape
and
rate
must be specified.
df
and scale
must be specified for an inverse Wishart prior. shape
and rate
are required for an inverse gamma prior. For structural models or models with stochastic volatility
only a gamma prior specification is allowed.
The argument ssvs
can contain the following elements
inprior
a numeric between 0 and 1 specifying the prior probability of a variable to be included in the model. Default is 0.5.
tau
a numeric vector of two elements containing the prior standard errors
of restricted variables (\tau_0
) as its first element and unrestricted variables (\tau_1
)
as its second. Default is c(0.05, 10)
.
semiautomatic
an numeric vector of two elements containing the
factors by which the standard errors associated with an unconstrained least squares
estimate of the country VARX model are multiplied to obtain the prior standard errors
of restricted (\tau_0
) and unrestricted (\tau_1
) variables. This is the
semiautomatic approach described in George et al. (2008).
exclude_det
logical indicating whether deterministic terms should be excepted from SSVS.
Either tau
or semiautomatic
must be specified.
The argument bvs
can contain the following elements
inprior
a numeric between 0 and 1 specifying the prior probability of a variable to be included in the model. Default is 0.5.
minnesota
a numeric vector of length 4 containing parameters for the calculation of Minnesota-like inclusion priors, where
\kappa_{1}{l} \textrm{ for own lags of domestic endogenous variables,}
\frac{\kappa_{2}}{l} \textrm{ for domestic endogenous variables other than own lags,}
\frac{\kappa_{3}}{l + 1} \textrm{ for foreign and global exogenous variables,}
\kappa_{4} \textrm{ for deterministic terms.}
The indices of \kappa
correspond to the positions of the elements in the argument kappa
.
exclude_det
logical indicating whether deterministic terms should be excepted from BVS.
A list of country models.
Chan, J., Koop, G., Poirier, D. J., & Tobias J. L. (2019). Bayesian econometric methods (2nd ed.). Cambridge: Cambridge University Press.
George, E. I., Sun, D., & Ni, S. (2008). Bayesian stochastic search for VAR model restrictions. Journal of Econometrics, 142(1), 553–580. https://doi.org/10.1016/j.jeconom.2007.08.017
Korobilis, D. (2013). VAR forecasting using Bayesian variable selection. Journal of Applied Econometrics, 28(2), 204–230.
# Load data
data("gvar2019")
# Create regions
temp <- create_regions(country_data = gvar2019$country_data,
weight_data = gvar2019$weight_data,
region_weights = gvar2019$region_weights,
regions = list(EA = c("AT", "BE", "DE", "ES", "FI", "FR", "IT", "NL")),
period = 3)
country_data <- temp$country_data
weight_data <- temp$weight_data
global_data = gvar2019$global_data
# Difference series to make them stationary
country_data <- diff_variables(country_data, variables = c("y", "Dp", "r"), multi = 100)
global_data <- diff_variables(global_data, multi = 100)
# Create time varying weights
weight_data <- create_weights(weight_data, period = 3, country_data = country_data)
# Generate specifications
model_specs <- create_specifications(
country_data = country_data,
global_data = global_data,
countries = c("US", "JP", "CA", "NO", "GB", "EA"),
domestic = list(variables = c("y", "Dp", "r"), lags = 1),
foreign = list(variables = c("y", "Dp", "r"), lags = 1),
global = list(variables = c("poil"), lags = 1),
deterministic = list(const = TRUE, trend = FALSE, seasonal = FALSE),
iterations = 10,
burnin = 10)
# Note that the number of iterations and burnin draws should be much higher!
# Overwrite country-specific specifications
model_specs[["US"]][["domestic"]][["variables"]] <- c("y", "Dp", "r")
model_specs[["US"]][["foreign"]][["variables"]] <- c("y", "Dp")
# Create estimation objects
country_models <- create_models(country_data = country_data,
weight_data = weight_data,
global_data = global_data,
model_specs = model_specs)
# Add priors
models_with_priors <- add_priors(country_models,
coef = list(v_i = 1 / 9, v_i_det = 1 / 10),
sigma = list(df = 3, scale = .0001))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.