Skip to main content

drvarma

Exact maximum-likelihood estimation, forecasting and diagnostics of multivariate VARMA (vector ARMA) models — in pure Python, with an optional compiled C engine for speed.

import numpy as np
from drvarma import Model, datasets

series = datasets.simulate_varma(phi=[np.diag([0.5, 0.4, 0.3])], sigma=np.eye(3),
                                 n=300, mu=[100., 50., 75.], seed=1,
                                 names=["A", "B", "C"])
m = Model(series, p=2, q=0, include_mean=True).fit()
print(m.phi, m.sigma, m.loglik)
levels, lo, hi = m.forecast(12, bands=True)     # + 95% bands
print(m.diagnostics())                          # Hosking Q, Jarque-Bera

drvarma fits a stationary Gaussian VARMA(p, q), Φ(B)(wₜ − μ) = Θ(B) aₜ, aₜ ~ N(0, Σ), by exact maximum likelihood (no conditional/back-forecasting approximation), and gives forecasts (+ error bands), impulse responses, variance decompositions, residual diagnostics and volatility.

What this provides. drvarma is a pure-Python implementation of Mauricio's exact-likelihood algorithm for multivariate VARMA (1995 JASA / 1997 AS 311): an innovations-form factorisation that evaluates the exact Gaussian likelihood directly on the VARMA form, without a state-space / Kalman filter, maximised by a faithful factored-BFGS quasi-Newton. Exact ML for VARMA is also available in Python through state-space methods (e.g. statsmodels' Kalman-filter VARMAX); what drvarma adds is a faithful port of this specific, non-Kalman algorithm — which, as far as we know, is not otherwise available in Python — together with the surrounding forecasting/IRF/FEVD/diagnostics toolkit. It runs with no compiled code; the optional C engine is only an accelerator.

Install

pip install drvarma                       # pure-Python (numpy + scipy)

Optional extras: drvarma[plots] (matplotlib + pyfug charts), drvarma[forecast-report] (HTML forecast reports), drvarma[c-engine] (build the CFFI C engine — needs GSL dev headers, ~10–100× faster but optional).

Features

  • Exact-ML estimation of stationary VARMA(p, q) for general dimension m, with mean, diagonal AR/MA/covariance restrictions, and optional Hannan–Rissanen two-step start.
  • Forecasting in original units: level, period and annual variation, each with standard errors and 95 % bands; plus fixed-parameter recursive (out-of-sample) forecasting.
  • Structural analysis: orthogonalised impulse responses, accumulated responses, long-run gain, and the forecast-error variance decomposition.
  • Diagnostics: Hosking multivariate portmanteau, multivariate Jarque–Bera, per-series ACF/PACF and two-sided cross-correlation (CCF).
  • Volatility: exponential-weight and moving-window residual covariance.
  • Transforms: Box-Cox + regular/seasonal differencing and harmonic deseasonalisation (with re-seasonalised forecasts).
  • I/O & reports: .inp reader/writer, C-format .out/.forecast/ .recursive text reports, an HTML forecast report per series, and matplotlib charts.

Everything runs with no compiled code. The optional CFFI engine wraps the validated drvarma C core and is bit-compatible with the pure-Python path on well-conditioned problems — an accelerator only. The numerical methods are tabulated below; see docs/DEVELOPER_GUIDE.md for the complexity discussion and a pure-Python vs hybrid vs C performance study.

Command line

drvarma IPC3 3 0 -mean -deseason auto -forecast 24        # writes IPC3.out, .forecast
drvarma IPC3 3 0 -mean -forecast 24 -html                # + HTML report per series
drvarma IPC3 3 0 -mean -estwin 200 -forecast 12          # recursive (.recursive)
drvarma IPC3 3 0 -mean -volexp 0.05 20 -volmov 20        # volatility (.volexp/.volmov)

<file>.inp in, text reports out. Flags: -mean -diagar -diagma -diagcov -m {1,2} -twostep -deseason [auto|force] -scale S -forecast H -html -estwin N -volexp [α w] -volmov [w] (λ, d, D come from the .inp header).

Documentation

Numerical methods

Algorithm Reference Used for
Exact Gaussian VARMA log-likelihood (innovations factorisation, not Kalman) Mauricio (1995) JASA; Mauricio (1997) AS 311 Exact likelihood (drvarma._as311)
Factored-BFGS quasi-Newton + Dennis–Schnabel line search Dennis & Schnabel (1983) ML optimisation (drvarma._qnewt.raxopt)
Concentrated objective f1ᵐ·f2 (σ² profiled, Σ = σ²·Q) Mauricio (1995) JASA §3 Conditioning; covariance / std errors
Hannan–Rissanen two-step Hannan & Rissanen (1982) VARMA start (-twostep)
Companion-form Lyapunov / autocovariances Mauricio (1997) AS 311 Stationary covariance, ψ-weights
Orthogonalised IRF & FEVD (Cholesky of Σ) Lütkepohl (2005) Structural analysis
Hosking multivariate portmanteau; multivariate Jarque–Bera Hosking (1980); Jarque & Bera (1980) Residual diagnostics
Exponential / moving-window conditional covariance Volatility (drvarma.volatility)

Cross-references: Mauricio (2002, JTSA 23(4)) and Shea (1989, AS 242) are the other efficient exact-likelihood methods compared in the literature.

Authors and licence

drvarma is developed by David E. Guerrero and Arthur B. Treadway, based on the exact-likelihood algorithms designed and coded by José Alberto Mauricio.

Released under the GNU General Public License v2.0 or later (GPL-2.0-or-later) — see COPYING.

Download files

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

Source Distribution

drvarma-0.1.1.tar.gz (148.3 kB view details)

Uploaded Source

Built Distribution

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

drvarma-0.1.1-py3-none-any.whl (76.6 kB view details)

Uploaded Python 3

File details

Details for the file drvarma-0.1.1.tar.gz.

File metadata

  • Download URL: drvarma-0.1.1.tar.gz
  • Upload date:
  • Size: 148.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for drvarma-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5e5e84e2812c125eead0436bb83f9ce9c8a423185f595a995dedbbad3b399e2c
MD5 c2fa7d3e8c37ebbfb694c767e814b7ba
BLAKE2b-256 908dc288f505c62b6b4a0229d472a0e5898ff69e0496367bb6233af47e515801

See more details on using hashes here.

Provenance

The following attestation bundles were made for drvarma-0.1.1.tar.gz:

Publisher: publish.yml on davidesg/drvarma-python

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

File details

Details for the file drvarma-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: drvarma-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 76.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for drvarma-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 99c6a7b7fb48dca789ac690531f34060c4313b08c8a4f1392466cd3793c88dac
MD5 cb76cd3884e3b7fede3f14da620c5f77
BLAKE2b-256 3a4da545d703ecf66936d0b5cac3990721584855176305baac275fce72222643

See more details on using hashes here.

Provenance

The following attestation bundles were made for drvarma-0.1.1-py3-none-any.whl:

Publisher: publish.yml on davidesg/drvarma-python

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

Release history Release notifications | RSS feed

0.1.6

26 files

0.1.5

26 files

0.1.4

26 files

0.1.3

26 files

0.1.2

26 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

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