Skip to contents

Creates a grid of IRF plots showing responses of all variables to a single shock, with shaded confidence bands using ggplot2. Designed for Cholesky-identified VARs.

Usage

fplotirf_chol(
  point,
  upper,
  lower,
  shock,
  varnames,
  prc,
  return_data = FALSE,
  ribbon_fill = "#407EC9",
  ribbon_alpha = 0.3,
  line_color = "#910048",
  zero_line_color = "#707372",
  facet_scales = "free",
  facet_ncol = NULL
)

Arguments

point

Array of point estimates (N x N x horizon)

upper

Array of upper confidence bounds (N x N x horizon)

lower

Array of lower confidence bounds (N x N x horizon)

shock

Integer, which shock to plot (1-indexed, typically 1 to N)

varnames

Character vector of variable names (length N)

prc

Numeric, confidence level percentage (e.g., 68 or 95)

return_data

Logical, if TRUE returns tibble instead of plot

ribbon_fill

Color for confidence band fill (default: "#407EC9")

ribbon_alpha

Transparency for confidence band (default: 0.3)

line_color

Color for point estimate line (default: "#910048")

zero_line_color

Color for horizontal zero line (default: "#707372")

facet_scales

Facet scales option: "free", "free_y", "free_x", or "fixed" (default: "free")

facet_ncol

Number of columns in facet grid (default: NULL, auto-calculated)

Value

A ggplot object (if return_data = FALSE) or tibble (if return_data = TRUE)

Details

This function extracts the impulse responses of all N variables to a specific shock from 3D arrays (typically output from fbootstrapChol). The shock parameter selects which column (shock) to visualize across all response variables.

The plot uses the currently active ggplot2 theme. For a consistent look with other tidyMacro plots, use ftheme_tidyMacro() or set it globally with set_tidyMacro_theme().

Examples

if (FALSE) { # \dontrun{
# Estimate VAR and compute Cholesky IRF
var_result <- fVAR(y, p = 2, c = 1)
wold <- fwoldIRF(var_result, horizon = 20)
S <- t(chol(var_result$sigma_full))
point_irf <- fcholeskyIRF(wold, S)

# Bootstrap confidence bands
boot_result <- fbootstrapChol(y, var_result, nboot = 1000, 
                              horizon = 20, prc = 68, bootscheme = "residual")

# Plot responses to first shock
fplotirf_chol(point_irf, boot_result$upper, boot_result$lower, 
              shock = 1, varnames = c("GDP", "Inflation", "Interest Rate"),
              prc = 68)

# Use custom theme
fplotirf_chol(point_irf, boot_result$upper, boot_result$lower, 
              shock = 1, varnames = c("GDP", "Inflation", "Interest Rate"),
              prc = 68) +
  ftheme_tidyMacro()
} # }