
R6 Class representing the specification of the BVARs model
Source:R/specify_bvars.R
specify_bvars.RdThe class BVARs presents complete specification for the Bayesian Vector Autoregressions for cubic data.
References
Zellner (1971). An Introduction to Bayesian Inference in Econometrics. John Wiley & Sons.
Zellner, Hong (1989). Forecasting international growth rates using Bayesian shrinkage and other procedures. Journal of Econometrics, 40(1), 183–202, doi:10.1016/0304-4076(89)90036-5 .
Public fields
pa non-negative integer specifying the autoregressive lag order of the model.
prioran object PriorBSVAR with the prior specification.
data_matricesan object DataMatricesBVARPANEL with the data matrices.
starting_valuesan object StartingValuesBVARPANEL with the starting values.
adaptiveMHa vector of four values setting the adaptive MH sampler for nu: adaptive rate, target acceptance rate, the iteration at which to start adapting, the initial scaling rate
Methods
Method new()
Create a new specification of the Bayesian Panel VAR model BVARPANEL.
Usage
specify_bvars$new(
data,
p = 1L,
exogenous = NULL,
stationary = rep(FALSE, ncol(data[[1]])),
type = rep("real", ncol(data[[1]]))
)Arguments
dataa list with
Celements of(T_c+p)xNmatrices with time series data.pa positive integer providing model's autoregressive lag order.
exogenousa
(T+p)xdmatrix of exogenous variables.stationaryan
Nlogical vector - its element set toFALSEsets the prior mean for the autoregressive parameters of theNth equation to the white noise process, otherwise to random walk.typean
Ncharacter vector with elements set to "rate" or "real" determining the truncation of the predictive density to[0, 100]and(-Inf, Inf)(no truncation) for each of the variables.
Method get_data_matrices()
Returns the data matrices as the DataMatricesBVARPANEL object.
Examples
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$get_data_matrices()
Method get_prior()
Returns the prior specification as the PriorBVARPANEL object.
Examples
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$get_prior()
Method get_starting_values()
Returns the starting values as the StartingValuesBVARPANEL object.
Examples
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$get_starting_values()
Method get_type()
Returns the type of the model.
Examples
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$get_type()
Method set_prior2objective()
Sets the VAR model priors to objective prior by Zellner (1972).
Examples
data(ilo_dynamic_panel)
spec = specify_bvars$new(
data = ilo_dynamic_panel,
p = 4
)
spec$set_prior2objective()
Method set_global2pooled()
Sets the prior mean of the global autoregressive parameters to the OLS pooled panel estimator following Zellner, Hong (1989).
Arguments
xa vector of four values setting the adaptive MH sampler for nu: adaptive rate, target acceptance rate, the iteration at which to start adapting, the initial scaling rate
Examples
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$set_global2pooled()
Method set_adaptiveMH()
Sets the parameters of adaptive Metropolis-Hastings sampler for the parameter nu.
Arguments
xa vector of four values setting the adaptive MH sampler for nu: adaptive rate, target acceptance rate, the iteration at which to start adapting, the initial scaling rate
Examples
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$set_adaptiveMH(c(0.6, 0.4, 10, 0.1))
Examples
data(ilo_dynamic_panel)
spec = specify_bvars$new(
data = ilo_dynamic_panel,
p = 4
)
## ------------------------------------------------
## Method `specify_bvars$get_data_matrices`
## ------------------------------------------------
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$get_data_matrices()
#> <DataMatricesBVARPANEL>
#> Public:
#> Y: list
#> clone: function (deep = FALSE)
#> exogenous: list
#> get_data_matrices: function ()
#> initialize: function (data, p = 1L, exogenous = NULL, type = rep("real",
#> missing: list
#> type: real real real real
## ------------------------------------------------
## Method `specify_bvars$get_prior`
## ------------------------------------------------
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$get_prior()
#> <PriorBVARPANEL>
#> Public:
#> M: 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ...
#> S_Sigma_inv: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
#> S_inv: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
#> W: 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ...
#> a_w: 1
#> clone: function (deep = FALSE)
#> eta: 5
#> get_prior: function ()
#> initialize: function (C, N, p, d = 0, stationary = rep(FALSE, N))
#> lambda: 72
#> mu_Sigma: 5
#> mu_m: 1
#> nu_s: 3
#> s_s: 1
#> s_w: 1
#> sigma2_m: 1
## ------------------------------------------------
## Method `specify_bvars$get_starting_values`
## ------------------------------------------------
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$get_starting_values()
#> <StartingValuesBVARPANEL>
#> Public:
#> A: 0.999886768355647 -0.000138857547087093 -0.0014872568280 ...
#> A_c: 0.000285310550831959 -0.00126085352375624 -0.00041142686 ...
#> Sigma: 3.3241594394414 -0.662355402534803 -1.68551919882717 0.1 ...
#> Sigma_c: 4.81830309830798 0.839464635336795 -1.38664902195596 -4. ...
#> V: 12.7575683842514 2.93365107399473 -5.4701524580877 -5.30 ...
#> clone: function (deep = FALSE)
#> get_starting_values: function ()
#> initialize: function (C, N, p, d = 0)
#> m: -0.000691588376780355
#> nu: 5.1
#> s: 0.415564010992555
#> set_starting_values: function (last_draw)
#> w: 0.32673488605282
## ------------------------------------------------
## Method `specify_bvars$get_type`
## ------------------------------------------------
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$get_type()
#> [1] "wozniak"
## ------------------------------------------------
## Method `specify_bvars$set_prior2objective`
## ------------------------------------------------
data(ilo_dynamic_panel)
spec = specify_bvars$new(
data = ilo_dynamic_panel,
p = 4
)
spec$set_prior2objective()
#> Setting the model priors to objective prior by Zellner (1972).
## ------------------------------------------------
## Method `specify_bvars$set_global2pooled`
## ------------------------------------------------
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$set_global2pooled()
## ------------------------------------------------
## Method `specify_bvars$set_adaptiveMH`
## ------------------------------------------------
data(ilo_dynamic_panel)
spec = specify_bvarPANEL$new(
data = ilo_dynamic_panel,
p = 4
)
spec$set_adaptiveMH(c(0.6, 0.4, 10, 0.1))