Learn R Programming

lpirfs (version 0.1.2)

lp_lin_iv: Compute linear impulse responses with identified shock (instrument variable approach)

Description

Compute linear impulse responses with local projections and identified shock, i.e. instrument variable approach (see e.g. Jord<U+00E0> et al., 2015; and Ramey and Zubairy, 2018).

Usage

lp_lin_iv(endog_data, instr = NULL, lags_endog_lin = NULL,
  exog_data = NULL, lags_exog = NULL, contemp_data = NULL,
  lags_criterion = NaN, max_lags = NaN, trend = NULL,
  confint = NULL, hor = NULL, num_cores = NULL)

Arguments

endog_data

A data.frame, containing the dependent variables.

instr

One column data.frame including the values of the instrument to shock with. The row length has to be the same as endog_data.

lags_endog_lin

NaN or integer. NaN if lags are chosen by lag length criterion. Integer for number of lags for endog_data.

exog_data

A data.frame, containing exogenous variables for the VAR. The row length has to be the same as endog_data. Lag lengths for exogenous variables have to be given and will no be determined via a lag length criterion.

lags_exog

NULL or Integer. Integer for the number of lags for the exogenous data.

contemp_data

A data.frame, containing exogenous data with contemporaneous impact. The row length has to be the same as endog_data.

lags_criterion

NaN or character. NaN means that the number of lags will be given at lags_endog_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.

confint

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

hor

Integer. Number of horizons for impulse responses.

num_cores

NULL or Integer. The number of cores to use for the estimation. If NULL, the function will use the maximum number of cores minus one.

Value

A list containing:

irf_lin_mean

A matrix containing the impulse responses. The row in each matrix denotes the response of the ith variable to the (instrument) shock. The columns are the horizons.

irf_lin_low

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

irf_lin_up

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

specs

A list with properties of endog_data for the plot function. It also contains lagged data (y_lin and x_lin) used for the estimations of the irfs.

References

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

Auerbach, A. J., and Gorodnichenko Y. (2012). "Measuring the Output Responses to Fiscal Policy." American Economic Journal: Economic Policy, 4 (2): 1-27.

Hurvich, C. M., and Tsai, C.-L. (1989), "Regression and time series model selection in small samples", Biometrika, 76(2): 297<U+2013>307

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

Jord<U+00E0>, <U+00D2>, Schularick, M., Taylor, A.M. (2015), "Betting the house", Journal of International Economics, 96, S2-S18.

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.

Ramey, V.A., and Zubairy, S. (2018). "Government Spending Multipliers in Good Times and in Bad: Evidence from US Historical Data." Journal of Political Economy, 126(2): 850 - 901.

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

See Also

https://adaemmerp.github.io/lpirfs/README_docs.html

Examples

Run this code
# NOT RUN {
# This example replicates a result from the Supplementary Appendix
# by Ramey and Zubairy (2018) (RZ-18).

# Load data
 ag_data       <- ag_data
 sample_start  <- 7
 sample_end    <- dim(ag_data)[1]

# Endogenous data
 endog_data    <- ag_data[sample_start:sample_end,3:5]

# Shock ('Instrument')
 shock         <- ag_data[sample_start:sample_end, 3]

# Estimate linear model
 results_lin_iv <- lp_lin_iv(endog_data,
                               lags_endog_lin = 4,
                               instr          = shock,
                               exog_data      = NULL,
                               lags_exog      = NULL,
                               contemp_data   = NULL,
                               lags_criterion = NaN,
                               max_lags       = NaN,
                               trend          = 0,
                               confint        = 1.96,
                               hor            = 20,
                               num_cores      = NULL)


# Make and save plots
 iv_lin_plots    <- plot_lin(results_lin_iv)

# * The first element of 'iv_lin_plots' shows the response of the first
#   variable (Gov) to the chosen (instrument-)shock (here Gov).
# * The second element of 'iv_lin_plots' shows the response of the second
#   variable (Tax) to the chosen (instrument-)shock (Gov).
# * ...

# This plot replicates the left plot in the mid-panel of Figure 12 in the
# Supplementary Appendix by RZ-18.
 iv_lin_plots[[1]]

# Show all impulse responses by using 'ggpubr' and 'gridExtra'
# The package does not depend on those packages so they have to be installed
 library(ggpubr)
 library(gridExtra)

 lin_plots_all <- sapply(iv_lin_plots, ggplotGrob)
 marrangeGrob(lin_plots_all, nrow = ncol(endog_data), ncol = 1, top = NULL)

# }

Run the code above in your browser using DataLab