% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/forecast.R
\name{forecast}
\alias{forecast}
\title{Forecast from a fitted steady-state BVAR model}
\usage{
forecast(
  x,
  pi = 0.95,
  fcst_type = c("mean", "median"),
  growth_rate_idx = NULL,
  plot_idx = NULL,
  show_all = FALSE
)
}
\arguments{
\item{x}{A steady-state \code{bvar} object that has been passed through \code{\link{fit}}.}

\item{pi}{Numeric. The prediction interval width. Default \code{0.95}, i.e. 95\% prediction interval.}

\item{fcst_type}{Character. Whether to use \code{"mean"} or \code{"median"}
as the point forecast. Default \code{"mean"}.}

\item{growth_rate_idx}{Integer vector. Indices of variables of which to convert forecasts to
annual growth rates \eqn{\ln x_{t} - \ln x_{t-f}}, where \eqn{f} is
the frequency of the data (4 for quarterly, 12 for monthly).
Only suitable for variables specified as \eqn{\ln x_{t} - \ln x_{t-1}}, i.e.
\code{diff(log(x))} or \code{100*diff(log(x))}.
Computed by summing up to \eqn{f} log first differences. Default is \code{NULL}.}

\item{plot_idx}{Integer vector. Indices of variables to plot. If \code{NULL}
(default), all variables are plotted. Forecasts are always computed and
returned for all variables, regardless of \code{plot_idx}.}

\item{show_all}{Logical. If \code{FALSE} (default), only the last two years
of history are shown alongside the forecast. If \code{TRUE}, the full
history is shown.}
}
\value{
Invisibly returns a list with three matrices: \code{forecast}, \code{lower}, and
\code{upper}, each of dimension \code{H x k} where \code{H} is the
forecast horizon and \code{k} is the number of variables.
}
\description{
Computes and plots forecasts from a fitted \code{bvar} object. Draws from the
joint predictive distribution are used to construct point forecasts and
prediction intervals. Optionally converts monthly or quarterly growth rate forecasts to annual growth
rates for selected variables.
}
\examples{
\donttest{
#homoscedastic with Jeffreys prior
yt <- matrix(rnorm(50), 25, 2)

bvar_obj <- bvar(data = yt)

bvar_obj <- setup(bvar_obj, p=1, deterministic = "constant")

bvar_obj <- priors(bvar_obj,
                   lambda_1 = 0.2,
                   lambda_2 = 0.5,
                   lambda_3 = 1,
                   first_own_lag_prior_mean = rep(1,2),
                   theta_Psi = rep(0, 2),
                   Omega_Psi = diag(0.1, 2, 2),
                   Jeffreys = TRUE,
                   SV = FALSE,
                   SV_type = NULL,
                   SV_priors = NULL)
                   
bvar_obj <- fit(bvar_obj,
                H = 8,
                d_pred = matrix(rep(1,8)),
                iter = 200,
                warmup = 50,
                chains = 1,
                cores = 1)

(fcst <- forecast(bvar_obj, pi = 0.90, show_all = TRUE))
}
}
