Using Exogenous Features (Covariates) in Chronax
This guide shows you how to incorporate external time series (covariates, or $X$) into your Chronax forecasting model to improve accuracy.
Prerequisites
- Chronax installed (
pip install chronax). - Data shaped as
jnp.ndarray, float32. - Crucially, the Chronax API specification is missing. The provided input describes a benchmarking configuration schema (
tempus_bench), not the Chronax library API (model names, constructor arguments, or method signatures). The steps below use placeholders (# TODO) where the Chronax API details are required.
Steps
1. Import necessary libraries and define data
You must import jax.numpy and define your target series (y) and your covariate series (X). Ensure $X$ is aligned with $y$ for the historical period.
import jax.numpy as jnp
# The Chronax API specification is missing.
# We need to know which models support covariates (e.g., AutoARIMA, NBEATS).
# from chronax.models import ModelWithX # TODO: confirm model name
# Define dummy data based on standard JAX/Chronax expectations (float32)
y = jnp.array([10.0, 12.0, 15.0, 14.0, 16.0], dtype=jnp.float32)
# X must have shape (T, D) where T is time steps and D is features.
X = jnp.array([[1.0, 0.5], [1.1, 0.6], [1.2, 0.7], [1.3, 0.8], [1.4, 0.9]], dtype=jnp.float32)
2. Initialize and fit the model using covariates
Chronax models typically accept the covariates $X$ as an optional argument to the fit method.
# The exact constructor arguments for Chronax models are unknown from the provided input.
# model = ModelWithX() # TODO: confirm model initialization arguments
# Assuming the standard fit contract: model.fit(y, X=X)
# model.fit(y, X=X) # TODO: confirm fit signature
print("Model fitting step requires Chronax API details.")
3. Predict future values using future covariates
When forecasting, you must provide the future values of the covariates (X_future) for the forecast horizon (h).
h = 3 # Forecast 3 steps ahead
# X_future must have shape (h, D)
X_future = jnp.array([[1.5, 1.0], [1.6, 1.1], [1.7, 1.2]], dtype=jnp.float32)
# Assuming the standard predict contract: model.predict(h, X=X_future)
# out = model.predict(h, X=X_future) # TODO: confirm predict signature
# print(out["mean"]) # TODO: confirm output dictionary keys
print("Prediction step requires Chronax API details.")
Full example
import jax.numpy as jnp
# from chronax.models import ModelWithX # API definition missing
# 1. Define data
y = jnp.array([10.0, 12.0, 15.0, 14.0, 16.0], dtype=jnp.float32)
X = jnp.array([[1.0, 0.5], [1.1, 0.6], [1.2, 0.7], [1.3, 0.8], [1.4, 0.9]], dtype=jnp.float32)
X_future = jnp.array([[1.5, 1.0], [1.6, 1.1], [1.7, 1.2]], dtype=jnp.float32)
h = 3
# 2. Initialize and fit
# model = ModelWithX() # API definition missing
# model.fit(y, X=X) # API definition missing
# 3. Predict
# out = model.predict(h, X=X_future) # API definition missing
print("Cannot generate runnable Chronax code. The provided input describes a benchmarking configuration schema, not the Chronax library API (models, methods, or array contracts).")
Next steps
- Review the Chronax documentation for specific model implementations (e.g.,
AutoARIMA,NBEATS). - Check the required covariate type (
past_future,past_only,future_only) for the chosenmodel. - Learn how to add
leveltopredictfor prediction intervals. - Explore multivariate forecasting using
chronax.models.M4.