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 |
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 |
simulate_predictive |
logical, indicating whether the posterior predictive distribution should be simulated. |
LPL |
logical indicating whether |
Y_obs |
Data matrix of observed values for computation of log predictive
likelihood. Each of |
LPL_VoI |
either integer vector or character vector of column-names
indicating for which subgroup of time-series in |
... |
Currently ignored! |
Value
Object of class bayesianVARs_predict
, a list that may contain the
following elements:
-
predictions
array of dimensionsc(length(ahead), ncol(object$Yraw), each * dim(object$PHI)[3])
containing the simulations from the predictive density (ifsimulate_predictive=TRUE
). -
LPL
vector of lengthlength(ahead)
containing the log-predictive-likelihoods (taking into account the joint distribution of all variables) (ifLPL=TRUE
). -
LPL_univariate
matrix of dimensionc(length(ahead), ncol(object$Yraw)
containing the marginalized univariate log-predictive-likelihoods of each series (ifLPL=TRUE
). -
LPL_VoI
vector of lengthlength(ahead)
containing the log-predictive-likelihoods for a subset of variables (ifLPL=TRUE
andLPL_VoI != NA
). -
Yraw
matrix containing the data used for the estimation of the VAR. -
LPL_draws
matrix containing the simulations of the log-predictive-likelihood (ifLPL=TRUE
). -
PL_univariate_draws
array containing the simulations of the univariate predictive-likelihoods (ifLPL=TRUE
). -
LPL_sub_draws
matrix containing the simulations of the log-predictive-likelihood for a subset of variables (ifLPL=TRUE
andLPL_VoI != NA
).
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