density.bvar {BVAR}  R Documentation 
Calculates densities of hyperparameters or coefficient draws from Bayesian
VAR models generated via bvar
. Wraps standard
density
outputs into a list
.
## S3 method for class 'bvar' density(x, vars = NULL, vars_response = NULL, vars_impulse = NULL, ...) ## S3 method for class 'bvar_density' plot(x, mar = c(2, 2, 2, 0.5), mfrow = c(length(x), 1), ...) independent_index(var, n_vars, lag)
x 
A 
vars 
Character vector used to select variables. Elements are matched
to hyperparameters or coefficients. Coefficients may be matched based on
the dependent variable (by providing the name or position) or the
explanatory variables (by providing the name and the desired lag). See the
example section for a demonstration. Defaults to 
vars_response 
Optional character or integer vectors used to select coefficents. Dependent variables are specified with vars_response, explanatory ones with vars_impulse. See the example section for a demonstration. 
vars_impulse 
Optional character or integer vectors used to select coefficents. Dependent variables are specified with vars_response, explanatory ones with vars_impulse. See the example section for a demonstration. 
... 

mar 
Numeric vector. Margins for 
mfrow 
Numeric vector. Rows for 
var, n_vars, lag 
Integer scalars. Retrieve the position of lag lag of variable var given n_vars total variables. 
Returns a list with outputs of density
.
# Access a subset of the fred_qd dataset data < fred_qd[, c("CPIAUCSL", "UNRATE", "FEDFUNDS")] # Transform it to be stationary data < fred_transform(data, codes = c(5, 5, 1), lag = 4) # Estimate a BVAR using one lag, default settings and very few draws x < bvar(data, lags = 1, n_draw = 1000L, n_burn = 200L, verbose = FALSE) # Get densities of the hyperparameters density(x) # Plot them plot(density(x)) # Only get the densities associated with dependent variable 1 density(x, vars_response = "CPI") # Check out the constant's densities plot(density(x, vars_impulse = 1)) # Get the densities of variable three's first lag density(x, vars = "FEDFUNDSlag1") # Get densities of lambda and the coefficients of dependent variable 2 density(x, vars = c("lambda", "UNRATE"))