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
Metadata
Release files for var-irf 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| var_irf-0.1.0.tar.gz | 7.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| var_irf-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.6 kB
Release files / var_irf-0.1.0.tar.gz
| Download URL | var_irf-0.1.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
38c1dc948d6f9f309e75ec4542b92a45675fcf71fc373c21e308151431b0285c
|
|
BLAKE2b-256 checksum How to use checksums |
c94049c320f43e903433e1c0867356d0218b83aff4c15b04fba99daa9c056479
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2025.
Transparency logRelease files / var_irf-0.1.0-py3-none-any.whl
| Download URL | var_irf-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f06560cee880c119e5bdbb9aeb9c8df1774d249afaca932564f16cb753da892
|
|
BLAKE2b-256 checksum How to use checksums |
29632f8bf2c216e5974ab66d37489c05d0e2bd5656fa3b1c37eac971232c054e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2025.
Transparency logSecurity for var-irf 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for var_irf-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.