Learn R Programming

lpirfs (version 0.1.0)

lp_lin: Compute linear impulse responses

Description

Compute linear impulse responses with local projections by Jord<U+00E0> (2005).

Usage

lp_lin(data_set_df, lags_lin = NULL, lags_criterion = NULL,
  max_lags = NULL, trend = NULL, shock_type = NULL, confint = NULL,
  hor = NULL)

Arguments

data_set_df

A data.frame() containing all endogenous variables for the VAR. The column order is used for the Cholesky decomposition.

lags_lin

NaN or integer. NaN if lag length criterion is used. Integer for number of lags for linear VAR.

lags_criterion

NaN or character. NaN means that the number of lags will be given at lags_lin. The character refers to the corresponding lag length criterion ('AICc', 'AIC' or 'BIC').

max_lags

NaN or integer. Maximum number of lags if lags_criterion is character with lag length criterion. NaN otherwise.

trend

Integer. No trend = 0 , include trend = 1, include trend and quadratic trend = 2.

shock_type

Integer. Standard deviation shock = 0, unit shock = 1.

confint

Double. Width of confidence bands. 68% = 1, 90% = 1.65, 95% = 1.96.

hor

Integer. Number of horizons for impulse responses.

Value

A list with impulse responses and their robust confidence bands. It also returns a list named specs with properties of data_set_df for the plot function.

irf_lin_mean

A three 3D array() containing all impulse responses for all endogenous variables. The last dimension denotes the shock variable. The row in each matrix gives the responses of the ith variable, ordered as in data_set_df. The columns denote the horizon. For example, if results_lin contains the list with results, results_lin$irf_lin_mean[, , 1] returns a KXH matrix, where K is the number of variables and H the number of horizons. '1' is the variable shock variable, corresponding to the variable in the first column of data_set_df.

irf_lin_low

A three 3D array() containing all lower confidence bands of the responses, based on robust standard errors by Newey and West (1987). Properties are equal to irf_lin_mean.

irf_lin_up

A three 3D array() containing all upper confidence bands of the responses, based on robust standard errors by Newey and West (1987). Properties are equal to irf_lin_mean.

specs

A list with properties of data_set_df for the plot function.

References

Akaike, H. (1974). "A new look at the statistical model identification", IEEE Transactions on Automatic Control, 19 (6): 716<U+2013>723.

Hurvich, C. M., and Tsai, C.-L. (1993) <U+201C>A Corrected Akaike Information Criterion for Vector Autoregressive Model Selection.<U+201D> Journal of Time Series Analysis, 1993, 14(3): 271<U+2013>79.

Jord<U+00E0>, <U+00D2>. (2005). "Estimation and Inference of Impulse Responses by Local Projections." American Economic Review, 95 (1): 161-182.

Newey W.K., and West K.D. (1987). <U+201C>A Simple, Positive-Definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix.<U+201D> Econometrica, 55: 703<U+2013>708.

Schwarz, Gideon E. (1978). "Estimating the dimension of a model", Annals of Statistics, 6 (2): 461<U+2013>464.

Examples

Run this code
# NOT RUN {
# Load package
  library(lpirfs)

# Load data
  data_set_df <- interest_rules_var_data

# Estimate linear model
  results_lin <- lp_lin(data_set_df, lags_lin       = 4,
                                     lags_criterion = NaN,
                                     max_lags       = NaN,
                                     trend          = 0L,
                                     shock_type     = 1L,
                                     confint        = 1.96,
                                     hor            = 12)

# Make plots
  linear_plots <- plot_lin_irfs(results_lin)

# Show single plots
  linear_plots[[1]]
  linear_plots[[2]]

# Show all plots
  library(ggpubr)
  library(gridExtra)

  lin_plots_all <- sapply(linear_plots, ggplotGrob)
  marrangeGrob(lin_plots_all, nrow = ncol(data_set_df), ncol = ncol(data_set_df), top = NULL)

 
# }

Run the code above in your browser using DataLab