Learn R Programming

lpirfs (version 0.1.3)

lp_nl_iv: Compute nonlinear impulse responses with identified shock

Description

Compute nonlinear impulse responses with local projections and identified shock. The data are separated into two states via a smooth transition function as applied in Auerbach and Gorodnichenko (2012).

Usage

lp_nl_iv(endog_data, lags_endog_nl = NULL, shock = NULL,
  instr = NULL, exog_data = NULL, lags_exog = NULL,
  contemp_data = NULL, lags_criterion = NULL, max_lags = NULL,
  trend = NULL, confint = NULL, hor = NULL, switching = NULL,
  use_hp = NULL, lambda = NULL, gamma = NULL, num_cores = NULL)

Arguments

endog_data

A data.frame, containing all endogenous variables for the VAR.

lags_endog_nl

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

shock

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

instr

Deprecated input name. Use shock instead. See shock for details.

exog_data

A data.frame, containing exogenous variables. 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. This data will not be lagged. 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_nl. Possible lag length criteria are 'AICc', 'AIC' or 'BIC'.

max_lags

NaN or integer. Maximum number of lags (if lags_criterion = 'AICc', 'AIC', 'BIC'). NaN otherwise.

trend

Integer. Include 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.

switching

Numeric vector. A column vector with the same length as endog_data. This series can either be decomposed via the Hodrick-Prescott filter (see Auerbach and Gorodnichenko, 2013) or directly plugged into the following smooth transition function: $$ F_{z_t} = \frac{exp(-\gamma z_t)}{1 + exp(-\gamma z_t)}. $$ Warning: \(F_{z_t}\) will be lagged by one and then multiplied with the data. If the variable shall not be lagged, the vector has to be given with a lead of one. The data for the two regimes are: Regime 1 = (1-\(F(z_{t-1})\))*y_(t-p), Regime 2 = \(F(z_{t-1})\)*y_(t-p).

use_hp

Boolean. Use HP-filter? TRUE or FALSE.

lambda

Double. Value of \(\lambda\) for the Hodrick-Prescott filter (if use_hp = TRUE).

gamma

Double. Positive number which is used in the transition function.

num_cores

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_s1_mean

A matrix, containing the impulse responses of the first regime. The row in each matrix denotes the responses of the ith variable to the shock. The columns are the horizons.

irf_s1_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_s1_mean.

irf_s1_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_s1_mean.

irf_s2_mean

A matrix, containing all impulse responses for the second regime. The row in each matrix denotes the responses of the ith variable to the shock. The columns denote the horizon.

irf_s2_low

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

irf_s2_up

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

specs

A list with properties of endog_data for the plot function. It also contains lagged data (y_nl and x_nl) used for the estimations of the impulse responses.

fz

A vector, containing the values of the transition function F(z_t-1).

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.

Auerbach, A. J., and Gorodnichenko Y. (2013). "Fiscal Multipliers in Recession and Expansion." NBER Working Paper Series. Nr 17447.

Blanchard, O., and Perotti, R. (2002). <U+201C>An Empirical Characterization of the Dynamic Effects of Changes in Government Spending and Taxes on Output.<U+201D> Quarterly Journal of Economics, 117(4): 1329<U+2013>1368.

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 results from the Supplementary Appendix
# by Ramey and Zubairy (2018) (RZ-18).

# Load and prepare data
 ag_data           <- ag_data
 sample_start      <- 7
 sample_end        <- dim(ag_data)[1]
 endog_data        <- ag_data[sample_start:sample_end, 3:5]

# The shock is estimated by RZ-18
 shock             <- ag_data[sample_start:sample_end, 7]

# Include four lags of the 7-quarter moving average growth rate of GDP
# as exogenous variables (see RZ-18)
 exog_data         <- ag_data[sample_start:sample_end, 6]

# Use the 7-quarter moving average growth rate of GDP as switching variable
# and adjust it to have suffiently long recession periods.
 switching_variable <- ag_data$GDP_MA[sample_start:sample_end] - 0.8

# Estimate local projections
 results_nl_iv <- lp_nl_iv(endog_data,
                           lags_endog_nl     = 3,
                           shock             = shock,
                           exog_data         = exog_data,
                           lags_exog         = 4,
                           contemp_data      = NULL,
                           lags_criterion    = NaN,
                           max_lags          = NaN,
                           trend             = 0,
                           confint           = 1.96,
                           hor               = 20,
                           switching         = switching_variable,
                           use_hp            = 0,
                           lambda            = NaN, # Ravn and Uhlig (2002):
                                                    # Annual data    = 6.25
                                                    # Quarterly data = 1600
                                                    # Monthly data   = 129,600
                           gamma             = 3,
                           num_cores         = NULL)

# Make and save plots
 plots_nl_iv <- plot_nl(results_nl_iv)

# Show single impulse responses
# Compare with red line of left plot (lower panel) in Figure 12 in Supplementary Appendix of RZ-18.
 plot(plots_nl_iv$gg_s1[[1]])
# Compare with blue line of left plot (lower panel) in Figure 12 in Supplementary Appendix of RZ-18.
 plot(plots_nl_iv$gg_s2[[1]])

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

 s1_plots <- sapply(plots_nl_iv$gg_s1, ggplotGrob)
 s2_plots <- sapply(plots_nl_iv$gg_s2, ggplotGrob)

# Show all responses of state 1
 marrangeGrob(s1_plots, nrow = ncol(endog_data), ncol = 1, top = NULL)

# Show all responses of state 2
 marrangeGrob(s2_plots, nrow = ncol(endog_data), ncol = 1, top = NULL)

# }

Run the code above in your browser using DataLab