Impulse Response Function (IRF) computation and plotting utilities built on statsmodels VAR
Project description
VAR-IRF
Impulse Response Function (IRF) utilities for VAR models with plotting helpers. Extracted from the workflow in test.ipynb.
Installation
pip install .
Once published to PyPI: pip install var-irf.
Repository: https://github.com/TianzhuQin/Vector-Autoregression-Impulse-Response-Function
Method summary (from the notebook)
- Fit a VAR(p) with
statsmodels.tsa.api.VAR(df).fit(lags). - Get IRF object via
fit(...).irf(h):- IRF values: cumulative
cum_effects(or non-cumulativeirfs). - Error bands:
- Asymptotic (
asym): build ±z·stderr from covariance. - Monte Carlo (
mc): direct lower/upper intervals.
- Asymptotic (
- IRF values: cumulative
- Plotting:
- Central IRF curve, gradient shaded bands, style options.
Quick start
import pandas as pd
import matplotlib.pyplot as plt
from var_irf import compute_irf, plot_irf
# df is a DataFrame with multiple series columns and a time index
result = compute_irf(df, lags=2, horizon=7, stderr_type="asym", orth=False)
fig, ax = plt.subplots(figsize=(10, 8))
plot_irf(result, "Series1", "Series2", ax=ax, direction="single", band="shaded", layout="overlay", shaded=True)
ax.axhline(0, color='r', linestyle='dashdot', linewidth=0.5)
plt.show()
API
compute_irf(df, lags=2, horizon=7, stderr_type='asym'|'mc', orth=False, cumulative=True, ...): Fit a VAR and return IRF arrays and error information.plot_irf(result, impulse, response, ax=None, direction='single'|'bi', band='shaded'|'interval', layout='overlay'|'side-by-side', shaded=True, ...): Plot using the result fromcompute_irfwith three orthogonal switches:- direction: single A→B or bidirectional.
- band: shaded (gradient) or interval (errorbar-like); set
shaded=Falsefor line-only. - layout: overlay in one axes or side-by-side two subplots.
plot_irf_from_dataframe(...): 直接从 DataFrame 计算并绘图。
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file var_irf-0.1.0.tar.gz.
File metadata
- Download URL: var_irf-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38c1dc948d6f9f309e75ec4542b92a45675fcf71fc373c21e308151431b0285c
|
|
| MD5 |
bb3b149bec3098a7862e51ce0d95edc9
|
|
| BLAKE2b-256 |
c94049c320f43e903433e1c0867356d0218b83aff4c15b04fba99daa9c056479
|
Provenance
The following attestation bundles were made for var_irf-0.1.0.tar.gz:
Publisher:
publish.yml on TianzhuQin/Vector-Autoregression-Impulse-Response-Function
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
var_irf-0.1.0.tar.gz -
Subject digest:
38c1dc948d6f9f309e75ec4542b92a45675fcf71fc373c21e308151431b0285c - Sigstore transparency entry: 638548817
- Sigstore integration time:
-
Permalink:
TianzhuQin/Vector-Autoregression-Impulse-Response-Function@aee02e04795674076d1181be4f0126e34efc2656 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/TianzhuQin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aee02e04795674076d1181be4f0126e34efc2656 -
Trigger Event:
push
-
Statement type:
File details
Details for the file var_irf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: var_irf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f06560cee880c119e5bdbb9aeb9c8df1774d249afaca932564f16cb753da892
|
|
| MD5 |
b0ec3ff0b94289780086fb78b27454fd
|
|
| BLAKE2b-256 |
29632f8bf2c216e5974ab66d37489c05d0e2bd5656fa3b1c37eac971232c054e
|
Provenance
The following attestation bundles were made for var_irf-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on TianzhuQin/Vector-Autoregression-Impulse-Response-Function
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
var_irf-0.1.0-py3-none-any.whl -
Subject digest:
4f06560cee880c119e5bdbb9aeb9c8df1774d249afaca932564f16cb753da892 - Sigstore transparency entry: 638548848
- Sigstore integration time:
-
Permalink:
TianzhuQin/Vector-Autoregression-Impulse-Response-Function@aee02e04795674076d1181be4f0126e34efc2656 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/TianzhuQin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aee02e04795674076d1181be4f0126e34efc2656 -
Trigger Event:
push
-
Statement type: