Creates area plots showing the forecast error variance decomposition (FEVD) for multiple variables across horizons.
Arguments
- fevd
A numeric array containing forecast error variance shares. Either a 3-dimensional array (N x N x horizon) for multiple shocks, or a 2-dimensional matrix (N x horizon) for a single shock.
- varnames
Character vector of variable names. Length should equal N (the number of variables).
- shocknames
Character vector of shock names. For 3-dimensional fevd, length should equal N. For 2-dimensional fevd, should be a single name.
- return_df
Logical. If
TRUE, returns a data frame instead of a plot. Default isFALSE.
Value
If return_df = FALSE, returns a ggplot object showing
the FEVD for each variable in separate facets. If return_df = TRUE,
returns a data frame in long format with columns: horizon, variable, shock,
and value.
Details
The function creates stacked area charts showing how forecast error variance is decomposed across different shocks over the forecast horizon. Each variable is displayed in a separate facet panel.
For 2-dimensional input (single shock), the function automatically calculates and displays "Other Shocks" as the complement to ensure the decomposition sums to 1.
