1 What Problem Does This Tool Solve?
Researchers in macroeconomics and applied time series regularly need to estimate impulse response functions (IRFs)—the dynamic path of a variable in response to a shock over multiple time horizons. Traditionally, IRFs were obtained from structural vector autoregressions (SVARS), which require specifying the full dynamics of a system of equations and imposing identifying restrictions on the contemporaneous relationships.
The local projection (LP) methodology of Jordà [2005] offers a flexible alternative. Instead of imposing a system-wide model, LP estimates the IRF at each horizon h by running a separate regression of the h-period-ahead outcome on the shock and controls. The approach is robust to misspecification, allows flexible covariate adjustment, and naturally accommodates instrumental variables (LP-IV) and nonlinear state-dependent effects.
The lpirfs R package, developed by Adämmer [2019], implements both linear and nonlinear LP in a user-friendly interface, with automatic Newey-West standard errors, support for IV estimation, and built-in plotting functions. This article walks through the key features with a concrete application to US macroeconomic data.
2 Installation and Setup
The package is available on CRAN. The current version (0.2.3) requires R >= 4.0.0 and has no external C++ dependencies, making installation straightforward on all platforms.
3 Linear Local Projections: lp_lin
3.1 The Core Function
The main function for linear LPs is lp_lin(). Its key arguments are:
• endog_data: a data frame containing the endogenous variables (response variables)
• lags_endog_lin: number of lags of endogenous variables to include as controls
• shock_var: name of the column to use as the shock variable (must be in endog_data)
• confound_vars: optional data frame of additional control variables (exogenous)
• hor: number of horizons to estimate (the length of the IRF)
• trend: 0 (no trend), 1 (linear trend), 2 (quadratic trend)
• use_nw: logical; use Newey-West standard errors (default TRUE)
• nw_lag: bandwidth for Newey-West kernel (default: horizon + 1)
• sig_criterion: criterion for lag selection ("AIC", "BIC", or fixed)
3.2 Application: Monetary Policy Shocks and Output
We estimate the dynamic effect of monetary policy shocks (as identified by Romer and Romer [2010]) on US industrial production. The Romer-Romer shock series is a narrative measure of monetary policy surprises, constructed as residuals from a Fed forecasting equation, and is widely used as an instrument.
The plot() method produces a grid of IRF plots with 90% and 95% confidence bands (shaded) for each endogenous variable in response to the shock. The x-axis is the horizon in quarters; the y-axis is the percentage-point response.
3.3 Interpreting the Output
The output object results_lin contains:
• irf_lin_mean: matrix of point estimates, dimension (horizon x num_endog)
• irf_lin_low: lower confidence band
• irf_lin_up: upper confidence band
• specs: list of all estimation options for reproducibility
A standard finding in this application is that a contractionary monetary shock (positive innovation to the federal funds rate) leads to a hump-shaped decline in GDP, bottoming out around 6-8 quarters after the shock, consistent with the real effects of monetary policy documented in the SVAR literature.
4 LP with External Instruments: lp_lin_iv()
When the shock variable is endogenous (e.g., the federal funds rate responds to economic conditions), identification requires an external instrument. The lp_lin_iv() function implements LP-IV:
where epsilon_hat_t is the first-stage fitted value of the endogenous shock from an instrument Zt.
The function runs a two-step procedure: first stage OLS of the shock on the instrument (and controls) at t; second stage LP regression using fitted values. Standard errors from use_nw = TRUE are HAC-corrected for the moving average error structure.
Reporting note. Always report the first-stage F-statistic to check for weak instruments. lpirfs stores first-stage results accessible via results_iv$first_stage. An F-statistic below 10 signals potential weak-instrument problems [Staiger and Stock, 1997].
5 Nonlinear (State-Dependent) Local Projections: lp_nl()
The nonlinear LP function lp_nl() implements the smooth-transition LP of Auerbach and Gorodnichenko [2012]:
The argument switching takes a numeric vector: the state variable zt. When use_logistic = TRUE, the transition function is F(zt) = (1 + e^-gamma*zt)^-1, where gamma controls the speed of transition. The output separates IRFs in the "high state" (large F(zt)) and "low state" (small F(zt)).
6 Key Options and Pitfalls
6.1 Choosing the Number of Lags
Lag selection matters for LP because the controls Wt-j must absorb enough serial correlation to make the residual u(h)t+h approximately orthogonal to past shocks. Setting sig_criterion = "AIC" selects the lag order by AIC up to max_lags. In small samples (fewer than 100 observations), prefer "BIC" as it imposes a stronger penalty for additional parameters.
6.2 Newey-West Bandwidth
The LP residual at horizon h follows a moving average of order h by construction. The Newey-West bandwidth should be at least h + 1. Setting nw_lag = NULL enables automatic bandwidth selection; alternatively, set it to h + 1 manually via a wrapper that calls lp_lin() separately for each horizon.
6.3 Horizon Length
Longer IRF horizons reduce the effective sample size (fewer observations contribute to the regression at distant horizons). With T observations and horizon H, the regression at horizon h uses T - h observations. Avoid horizons larger than T/4 to prevent precision from collapsing.
6.4 Comparing with SVAR
If you have a correctly specified SVAR, it will be more efficient than LP. Use LP when:
• You are uncertain about the correct SVAR lag structure or identification
• You want to test robustness of SVAR results to dynamic misspecification
• You want to add nonlinear state-dependence without specifying the full nonlinear system
The theoretical equivalence result of Plagborg-Møller and Wolf [2021] ensures that LP and correctly specified SVAR identify the same IRF asymptotically, so the choice is primarily about efficiency and robustness.
7 A Minimal Working Example
8 Comparison to Alternatives
Table 1: Comparison of IRF estimation packages in R
For researchers committed to the LP approach who want to go beyond OLS—for example, estimating ADRF-type treatment effects for continuous shocks using the GPS framework—combining lpirfs with custom sieve estimators or the npcausal package is a productive direction.
9 Conclusion
The lpirfs package brings the flexibility of Jordà [2005] local projections to an accessible R interface, supporting both linear and nonlinear IRF estimation, instrumental variable identification, and publication-quality plots. For researchers studying dynamic causal effects in time-series settings—monetary policy transmission, fiscal multipliers, climate-economy dynamics—lpirfs is a natural starting point, easy to use out of the box and extensible for more complex designs.
References
- Adämmer, P. (2019). lpirfs: An R package to estimate impulse response functions by local projections. R Journal, 11(2):421-438.
- Auerbach, A. J. and Gorodnichenko, Y. (2012). Measuring the output responses to fiscal policy. American Economic Journal: Economic Policy, 4(2):1-27.
- Jordà, Ò. (2005). Estimation and inference of impulse responses by local projections. American Economic Review, 95(1):161-182.
- Plagborg-Møller, M. and Wolf, C. K. (2021). Local projections and VARs estimate the same impulse responses. Econometrica, 89(2):955-980.
- Romer, C. D. and Romer, D. H. (2010). The macroeconomic effects of tax changes: Estimates based on a new measure of fiscal shocks. American Economic Review, 100(3):763-801.
- Staiger, D. and Stock, J. H. (1997). Instrumental variables regression with weak instruments. Econometrica, 65(3):557-586.
- Stock, J. H. and Watson, M. W. (2018). Identification and estimation of dynamic causal effects in macroeconomics using external instruments. Economic Journal, 128(610):917-948.