statsmodels.tsa.vector_ar.local_proj.LocalProjections#
- class statsmodels.tsa.vector_ar.local_proj.LocalProjections(endog, shock_idx=0, lags=1, horizons=12, exog=None, trend='c', nw_lags=None)[source]#
Local Projections estimator for impulse response functions.
For each horizon \(h = 0, 1, \ldots, H\), the impulse response is estimated by running a separate OLS regression
\[y_{t+h} = \alpha_h + \boldsymbol{\beta}_h \mathbf{z}_t + \boldsymbol{\Gamma}_h \mathbf{x}_t + \varepsilon_{t+h},\]where \(\mathbf{z}_t\) are the shock variables and \(\mathbf{x}_t\) contains lagged controls. Standard errors are Newey-West HAC-corrected with a bandwidth of at least \(h\) lags to account for the MA(\(h\)) serial correlation in the residuals.
- Parameters:
- endogarray_like,
shape(T,n)or(T,) Endogenous variables. A 1-D input is treated as a single variable.
- shock_idx
intorlist[int],optional Column index/indices within endog whose contemporaneous value enters as the shock. Defaults to
0(the first variable).- lags
int,optional Number of lagged values of all endog variables to include as controls. Defaults to
1.- horizons
int,optional Maximum IRF horizon \(H\). Regressions are run for \(h = 0, 1, \ldots, H\). Defaults to
12.- exogarray_like,
shape(T,k)orNone,optional Additional exogenous controls (e.g. time dummies, external instruments). Do not include a constant; it is added automatically.
- trend{“n”, “c”, “ct”},
optional Deterministic trend:
"n"none,"c"constant (default),"ct"constant plus linear trend.- nw_lags
intorNone,optional Override the automatic Newey-West bandwidth. When None (default) the bandwidth at horizon \(h\) is
max(h, ceil(4*(max(h,1)/100)^{2/9})).
- endogarray_like,
Methods
fit()Estimate LP-IRFs by running H+1 OLS regressions.
See also
statsmodels.tsa.vector_ar.var_model.VARVector autoregression model, whose Cholesky-orthogonalized impulse responses are the VAR-based analogue of the estimator here.
statsmodels.tsa.vector_ar.svar_model.SVARStructural vector autoregression model, for identification schemes other than a simple recursive ordering.
statsmodels.tsa.vector_ar.irf.IRAnalysisImpulse response object returned by
VAR.fit, sharing the same “shock ordered first” identification assumption.
Notes
Identification follows a recursive (Cholesky-style) scheme in which the variable(s) named by shock_idx are assumed to be ordered first, i.e. contemporaneously exogenous to the remaining variables in endog: only the lagged values of the other variables enter each regression, never their current-period values. This is the same “shock ordered first” assumption underlying Cholesky-orthogonalized VAR impulse responses (see
IRAnalysis), and the fitted coefficient on shock_idx only has a structural impulse-response interpretation to the extent that assumption is credible for the data at hand. When shock_idx names more than one column, those columns enter the regression together as ordinary simultaneous regressors with no orthogonalization among themselves; their coefficients are only separately identified as shocks if those variables are themselves mutually contemporaneously exogenous.References
Jordà, Ò. (2005). Estimation and Inference of Impulse Responses by Local Projections. American Economic Review, 95(1), 161–182.
Examples
>>> import numpy as np >>> from statsmodels.tsa.api import LocalProjections >>> rng = np.random.default_rng(0) >>> T, n = 200, 2 >>> e = rng.standard_normal((T, n)) >>> y = np.cumsum(e, axis=0) >>> lp = LocalProjections(y, shock_idx=0, lags=2, horizons=8) >>> res = lp.fit() >>> res.irfs.shape (9, 2, 1)
Methods
fit()Estimate LP-IRFs by running H+1 OLS regressions.