plot_irfs | R Documentation |
plot_irfs
plots impulse response functions for a given array
containing the impulse responses and possibly also error bands. This function
returns a list of figures containing IRFs per variable.
plot_irfs(irf_arr, var_names, plot_title = "", label_y = TRUE)
irf_arr |
Matrix or array of dimension |
var_names |
Vector of variable names of the |
plot_title |
Title of the figure |
label_y |
Should the variable name be printed next to y-axis? |
list containing the figures
# Create a random IRF array: in case a matrix, rows denote the
# periods ahead while the columns are the reactions of the variables
h <- 24 # IRF horizon
q <- 4 # number of variables
irf_ex <- matrix(stats::rnorm((h+1)*q), h+1, q)
irf_ex <- apply(irf_ex, 2, cumsum)
p1 <- plot_irfs(irf_arr = irf_ex, var_names = letters[1:q])
# in case the supplied IRF element is array, the interpretation is as follows
# 1st dimension: length of the IRF horizon, 2nd dimension contain the
# lower error band, point estimate and upper error band estimates,
# 3rd is the of variables
irf_arr <- c(irf_ex-sd(irf_ex)*1.645, irf_ex, irf_ex+sd(irf_ex)*1.645) %>%
array(dim= c(h+1, q, 3)) %>%
aperm(c(1,3,2))
p2 <- plot_irfs(irf_arr, var_names = letters[1:4], label_y = FALSE)
## Not run:
gridExtra::marrangeGrob(c(p1,p2), nrow = 4, ncol = 2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.