Description Usage Arguments Value Author(s) References See Also Examples

Compute nonlinear impulse responses with local projections and identified shock. The data can be separated into two states by a smooth transition function as applied in Auerbach and Gorodnichenko (2012), or by a simple dummy approach.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ```
lp_nl_iv(
endog_data,
lags_endog_nl = NULL,
shock = NULL,
instr = NULL,
exog_data = NULL,
lags_exog = NULL,
contemp_data = NULL,
lags_criterion = NaN,
max_lags = NaN,
trend = NULL,
confint = NULL,
use_nw = TRUE,
nw_lag = NULL,
nw_prewhite = FALSE,
adjust_se = FALSE,
hor = NULL,
switching = NULL,
lag_switching = TRUE,
use_logistic = TRUE,
use_hp = NULL,
lambda = NULL,
gamma = NULL,
num_cores = 1
)
``` |

`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 |

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

`instr` |
Deprecated input name. Use |

`exog_data` |
A data.frame, containing exogenous variables. The row length has to be the same as |

`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 |

`lags_criterion` |
NaN or character. NaN means that the number of lags
will be given at |

`max_lags` |
NaN or integer. Maximum number of lags (if |

`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. |

`use_nw` |
Boolean. Use Newey-West (1987) standard errors for impulse responses? TRUE (default) or FALSE. |

`nw_lag` |
Integer. Specifies the maximum lag with positive weight for the Newey-West estimator. If set to NULL (default), the lag increases with with the number of horizon. |

`nw_prewhite` |
Boolean. Should the estimators be pre-whitened? TRUE of FALSE (default). |

`adjust_se` |
Boolen. Should a finite sample adjsutment be made to the covariance matrix estimators? TRUE or FALSE (default). |

`hor` |
Integer. Number of horizons for impulse responses. |

`switching` |
Numeric vector. A column vector with the same length as
Warning: |

`lag_switching` |
Boolean. Use the first lag of the values of the transition function? TRUE (default) or FALSE. |

`use_logistic` |
Boolean. Use logistic function to separate states? TRUE (default) or FALSE. If FALSE, the values of the switching variable have to be binary (0/1). |

`use_hp` |
Boolean. Use HP-filter? TRUE or FALSE. |

`lambda` |
Double. Value of |

`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. |

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 |

`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_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_s2_mean` |
A matrix, containing all impulse responses for the second regime.
The row in each matrix denotes the responses of the |

`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_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 |

`specs` |
A list with properties of |

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

Philipp Adämmer

Akaike, H. (1974). "A new look at the statistical model identification", *IEEE Transactions on Automatic Control*, 19 (6): 716–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). “An Empirical Characterization of the
Dynamic Effects of Changes in Government Spending and Taxes on Output.” *Quarterly
Journal of Economics*, 117(4): 1329–1368.

Hurvich, C. M., and Tsai, C.-L. (1989), "Regression and time series model selection in small samples",
*Biometrika*, 76(2): 297–307

Jordà, Ò. (2005) "Estimation and Inference of Impulse Responses by Local Projections."
*American Economic Review*, 95 (1): 161-182.

Jordà, Ò, Schularick, M., Taylor, A.M. (2015), "Betting the house", *Journal of International Economics*,
96, S2-S18.

Newey, W.K., and West, K.D. (1987). “A Simple, Positive-Definite, Heteroskedasticity and
Autocorrelation Consistent Covariance Matrix.” *Econometrica*, 55, 703–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–464.

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | ```
# 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,
trend = 0,
confint = 1.96,
hor = 20,
switching = switching_variable,
use_hp = FALSE,
gamma = 3)
# Show all impulse responses
plot(results_nl_iv)
# Make and save individual 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 diagnostics. The first element shows the reaction of the first endogenous variable.
summary(results_nl_iv)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.