Skip to main content

Gradient update Vector Autoregression modeling library

Project description

GradVAR

Gradient update Vector Autoregression modeling library

Modeling with Vector Autoregression

Vector Autoregression (VAR) is a statistical model used to capture the linear interdependencies among multiple time series data. It generalizes the univariate autoregressive model to multiple time series, allowing each variable to be modeled as a linear function of its own past values and the past values of other variables in the system.

A VAR model with $k$ variables and $p$ lags can be expressed as a system of equations:

$$ Y_t = \mu + \sum_{i=1}^{p} A_i Y_{t-i} + \epsilon_t $$

Where:

  • $Y_t$ is the vector of endogenous variables at time $t$
  • $\mu$ is a vector of constants (intercepts),
  • $A_i$ is a matrix of coefficients for the $i$-th lag,
  • $p$ is the number of lags,
  • $\epsilon_t$ is a vector of error terms (shocks or innovations) at time $t$

Why this lib?

Traditional Vector Autoregression (VAR) models require continuous time series and are often estimated using least squares methods, which can be inefficient for large datasets or evolving time series. GradVAR introduces a more flexible and adaptive approach by leveraging gradient-based optimization techniques.

  • Discontinuous Time Series Unlike standard VAR models, GradVAR can be used to process time series with missing observations or irregular sampling
  • Gradient-Based Matrix Optimization Instead of relying on closed-form solutions, GradVAR optimizes the coefficient matrices using gradient descent, allowing for better performance on large datasets.
  • Incremental Training with New Data GradVAR allows continuous learning by updating the existing model with new observations.
  • Custom Loss Functions and Weighting You can define your own loss function and assign weights to different time periods or variables, tailoring the model to specific forecasting needs.

Pre-requisites

The library works on simple data matrices, data frame functionality is out of scope for this library and should be implemented elsewhere.

  • Stationary Data Ensure the time series is stationary; differencing or transformation may be needed.
  • Standardized Data Use z-score normalization for consistent scaling across variables before calling the library, or use batch normalization externally

Why Use JAX?

JAX is a powerful framework that combines NumPy-like syntax with automatic differentiation and just-in-time (JIT) compilation and GPU/TPU support. Further, the gradient update is done by the Adam optimizer.

Installation

Install via pip

The library can be installed directly from the repository using:

  pip install gradvar@git+https://github.com/martinlie/gradvar.git@main#egg=gradvar

into the current environment.

Install the Library Locally

Use pip install -e to create an editable installation, by first cloning the repository and then:

  pip install -e <path to gradvar>

This creates a symbolic link to your library directory, so changes in the library are immediately reflected in any project that uses it.

Usage

Refer to the examples folder for notebooks that demonstrate how to use the library.

Development

Build the library

pip install -r requirements-dev.txt
pip install -r requirements.txt
python -m build

Release WHL file

conda install gh --channel conda-forge
gh auth login
gh release create release-0.1.0 dist/gradvar-0.1.0-py3-none-any.whl --generate-notes

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

gradvar-2025.3.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

gradvar-2025.3.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file gradvar-2025.3.1.tar.gz.

File metadata

  • Download URL: gradvar-2025.3.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gradvar-2025.3.1.tar.gz
Algorithm Hash digest
SHA256 2f107d27341436e9c934558f63235aad0bcba5528a33016495c2c7d5647c1173
MD5 73218da15340ee3422be3140c7c3761d
BLAKE2b-256 85a421aa317fc1995bd85688c671cb9455f483a14e623205bd877eade9b85ecc

See more details on using hashes here.

File details

Details for the file gradvar-2025.3.1-py3-none-any.whl.

File metadata

  • Download URL: gradvar-2025.3.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gradvar-2025.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c67ec69792c93971ef024dbcee560f52e08d71f729219d0141d3aa9b53c4a2b
MD5 38e2aa641ab57c890db39a236a421cc0
BLAKE2b-256 954ed2c90946dfbe3922d8ec40f3f053c4861c3f34e9c9a6d8f8815cd6812873

See more details on using hashes here.

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