scenarios: scenarios function (fully optimized with Rcpp) This function...

View source: R/scenarios.r

scenariosR Documentation

scenarios function (fully optimized with Rcpp) This function computes the mean and covariances to draw from the conditional forecast The actual draw is done in the simscen function

Description

scenarios function (fully optimized with Rcpp) This function computes the mean and covariances to draw from the conditional forecast The actual draw is done in the simscen function

Usage

scenarios(
  h = 3,
  path = NULL,
  obs = NULL,
  free_shocks = NULL,
  n_sample = NULL,
  data_ = NULL,
  g = NULL,
  Sigma_g = NULL,
  posterior = NULL,
  matrices = NULL
)

Arguments

h

forecast horizon

path

conditional path of observables

obs

position of observable(s)

free_shocks

position of non-driving shocks (NA if all driving)

n_sample

Number of draws to sample (<= n_draws)

data_

Optional matrix of data (default taken from matrices$Z). Note: the last observation in data_ is used as the starting point; it should not overlap with the scenario forecasting period.

g

Optional matrix of non-driving shocks

Sigma_g

Optional covariance matrix of non-driving shocks

posterior

Optional posterior object (default taken from calling environment)

matrices

Optional matrices object from gen_mats() (default taken from calling environment)

Value

list of mu_eps, Sigma_eps, mu_y, Sigma_y, big_b, big_M, draws_used

Examples


library(APRScenario)
data(NKdata)

# Minimal example with a toy specification
spec <- bsvarSIGNs::specify_bsvarSIGN$new(as.matrix(NKdata[,2:4]), p = 1)
posterior <- bsvars::estimate(spec, S = 10)  # Use small S for fast test
matrices<-gen_mats(posterior = posterior, specification = spec)
# and having posterior object
 scenario_result <- scenarios(h = 2, 
                              path = c(1.0, 1.1), 
                              obs = 1, 
                              free_shocks = NA, 
                              posterior = posterior, 
                              matrices = matrices)


APRScenario documentation built on Dec. 22, 2025, 1:06 a.m.