predict.bayesianVARs_bvar {bayesianVARs}R Documentation

Predict method for Bayesian VARs

Description

Simulates from (out-of-sample) predictive density for Bayesian VARs estimated via bvar() and computes log predictive likelhoods if ex-post observed data is supplied.

Usage

## S3 method for class 'bayesianVARs_bvar'
predict(
  object,
  ahead = 1L,
  each = 1L,
  stable = TRUE,
  simulate_predictive = TRUE,
  LPL = FALSE,
  Y_obs = NA,
  LPL_VoI = NA,
  ...
)

Arguments

object

A bayesianVARs_bvar object, obtained from bvar().

ahead

Integer vector (or coercible to such), indicating the number of steps ahead at which to predict.

each

Single integer (or coercible to such) indicating how often should be drawn from the posterior predictive distribution for each draw that has been stored during MCMC sampling.

stable

logical indicating whether to consider only those draws from the posterior that fulfill the 'stable' criterion. Default is TRUE.

simulate_predictive

logical, indicating whether the posterior predictive distribution should be simulated.

LPL

logical indicating whether ahead-step-ahead log predictive likelihoods should be computed. If LPL=TRUE, Y_obs has to be specified.

Y_obs

Data matrix of observed values for computation of log predictive likelihood. Each of ncol(object$Yraw) columns is assumed to contain a single time-series of length length(ahead).

LPL_VoI

either integer vector or character vector of column-names indicating for which subgroup of time-series in object$Yraw a joint log predictive likelihood shall be computed.

...

Currently ignored!

Value

Object of class bayesianVARs_predict, a list that may contain the following elements:

See Also

stable_bvar(), plot.bayesianVARs_predict(), pairs.bayesianVARs_predict().

Examples

# Access a subset of the usmacro_growth dataset
data <- usmacro_growth[,c("GDPC1", "CPIAUCSL", "FEDFUNDS")]

# Split data in train and test
train <- data[1:(nrow(data)-4),]
test <- data[-c(1:(nrow(data)-4)),]

# Estimate model using train data only
mod <- bvar(train, quiet = TRUE)

# Simulate from 1-step to 4-steps ahead posterior predictive and compute
# log-predictive-likelihoods
predictions <- predict(mod, ahead = 1:4, LPL = TRUE, Y_obs = test)

# Summary
summary(predictions)

# Visualize via fan-charts
plot(predictions)


# In order to evaluate the joint predictive density of a subset of the
# variables (variables of interest), consider specifying 'LPL_VoI':
predictions <- predict(mod, ahead = 1:4, LPL = TRUE, Y_obs = test, LPL_VoI = c("GDPC1","FEDFUNDS"))
predictions$LPL_VoI


[Package bayesianVARs version 0.1.3 Index]