Local Projections
Calculate the impulse response of every ticker to a shock in another by local projections: how much a ticker moves 0, 1, 2, … periods after a one-unit move in the shock ticker (the independent ticker, the Benchmark by default), with a confidence band.
Each horizon has its own regression of the ticker h periods ahead on the shock today, with lags of both as controls (Jordà, 2005), so no VAR has to describe the whole system and a misspecified one does not carry its errors into the later horizons. On returns, the response at horizon 0 is close to the beta to the shock ticker, and the later horizons show whether the move continues or reverses; the cumulative response is that of the sum of the returns up to each horizon, close to the response of the price.
The formula is as follows:
\[y_{t+h} = \alpha_{h} + \beta_{h} \cdot s_{t} + \sum_{l=1}^{p} (\gamma_{h,l} \cdot y_{t-l} + \delta_{h,l} \cdot s_{t-l}) + \epsilon_{t+h}\] \[Y_{t+h} = \sum_{j=0}^{h} y_{t+j}\] \[\text{Lower Band}_{h} = \beta_{h} - z \cdot \text{SE}(\beta_{h})\] \[\text{Upper Band}_{h} = \beta_{h} + z \cdot \text{SE}(\beta_{h})\] \[z = \Phi_{\text{inv}}\left(\frac{1 + \texttt{confidence}}{2}\right)\]with y the ticker’s column (Return by default), s the shock ticker’s, \(h = 0\), …, H, H = periods (10 by default) and p = lags (1 by default). The cumulative response puts Y(t+h) on the left instead of y(t+h). The response at horizon h is \(\beta_{h}\), with SE the Newey-West standard error with h + 1 lags and \(\text{Phi}_{\text{inv}}\) the standard normal quantile function.
Also known as: local projection impulse response, LP-IRF, Jordà local projections.
Example · XLE, XLK, TLT · 2016 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_local_projections:
from financetoolkit import Toolkit
toolkit = Toolkit(
["XLE", "XLK", "TLT"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2016-01-01",
end_date="2025-12-31",
)
toolkit.econometrics.get_local_projections(period="weekly", periods=4)["TLT"]
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
How did the weekly return of the iShares 20+ Year Treasury Bond ETF respond in the four weeks after a move in the S&P 500 ETF, by local projections on data from 2016 to 2025?
Which returns:
| Horizon | Response | Standard Error | Lower | Upper | Observations |
|---|---|---|---|---|---|
| 0 | -0.0408 | 0.0515 | -0.1418 | 0.0603 | 520 |
| 1 | -0.0202 | 0.0591 | -0.1361 | 0.0957 | 519 |
| 2 | 0.0008 | 0.0461 | -0.0896 | 0.0912 | 518 |
| 3 | 0.0124 | 0.0390 | -0.0640 | 0.0888 | 517 |
| 4 | 0.0031 | 0.0399 | -0.0752 | 0.0814 | 516 |
5 rows
Using Your Own Data
get_local_projections runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:
from financetoolkit import Economics, Econometrics
economics = Economics(start_date="2000-01-01")
unemployment = economics.get_unemployment_rate(
countries=["United States", "Germany"], period="monthly"
)
econometrics = Econometrics(data=unemployment, changes="difference")
econometrics.get_local_projections()
Parameters
get_local_projections accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
independent_ticker | str | None | The ticker whose move is the shock. Defaults to None, which takes “Benchmark” when the data has it and the first ticker otherwise. | None, which takes "Benchmark" when the data has it and the first ticker otherwise |
period | str | The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”. | "weekly" |
column | str | The historical data column to model. Defaults to “Return”. | "Return" |
periods | int | The last horizon H, the number of periods ahead to trace the response out to. Defaults to 10. | 10 |
lags | int | The lags of the ticker and the shock used as controls. Defaults to 1. | 2 |
cumulative | bool | Whether to trace the cumulative response, the response of the price for returns. Defaults to False. | True |
confidence | float | The confidence level of the band. Defaults to 0.95. | 0.95 |
rounding | int | None | The number of decimals to round the results to. Defaults to None. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
References
- Paper Jordà, Ò. (2005). “Estimation and Inference of Impulse Responses by Local Projections.” American Economic Review, 95(1), 161-182.
- Library Referenced against statsmodels’ OLS