Skip to main content

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-cumulative irfs).
    • Error bands:
      • Asymptotic (asym): build ±z·stderr from covariance.
      • Monte Carlo (mc): direct lower/upper intervals.
  • 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 from compute_irf with three orthogonal switches:
    • direction: single A→B or bidirectional.
    • band: shaded (gradient) or interval (errorbar-like); set shaded=False for line-only.
    • layout: overlay in one axes or side-by-side two subplots.
  • plot_irf_from_dataframe(...): 直接从 DataFrame 计算并绘图。

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

var_irf-0.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

var_irf-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

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

Hashes for var_irf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 38c1dc948d6f9f309e75ec4542b92a45675fcf71fc373c21e308151431b0285c
MD5 bb3b149bec3098a7862e51ce0d95edc9
BLAKE2b-256 c94049c320f43e903433e1c0867356d0218b83aff4c15b04fba99daa9c056479

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for var_irf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f06560cee880c119e5bdbb9aeb9c8df1774d249afaca932564f16cb753da892
MD5 b0ec3ff0b94289780086fb78b27454fd
BLAKE2b-256 29632f8bf2c216e5974ab66d37489c05d0e2bd5656fa3b1c37eac971232c054e

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page