# \donttest{
# 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)
# Calculate a forecast with an increased horizon
y <- predict(x, horizon = 20)
# Add some confidence bands and store the forecast
predict(x) <- predict(x, conf_bands = c(0.05, 0.16))
# Recalculate with different settings and increased thinning
predict(x, bv_fcast(24L), n_thin = 10L)
# Simulate some new data to predict on
predict(x, newdata = matrix(rnorm(300), ncol = 3))
# Calculate a conditional forecast (with a constrained second variable).
predict(x, cond_path = c(1, 1, 1, 1, 1, 1), cond_var = 2)
# Get a summary of the stored forecast
summary(x)
# Only get the summary for variable #2
summary(x, vars = 2L)
# }
Run the code above in your browser using DataLab