TDgpt Introduces Covariate Forecasting

Joel Brass

June 13, 2025 /

The TDengine team is excited to announce that TDgpt now supports covariate forecasting for time-series data. This is currently implemented using the Moirai time-series foundation model, with additional models to be added in later versions.

What Is Covariate Forecasting?

Covariate forecasting refers to the practice of incorporating additional variables, referred to as covariates, into a time-series forecasting model. These variables, which may be historical, static, or even known in advance (such as a weather forecast or calendar event), provide context that can help the model make more informed and accurate predictions.

For instance, consider a model forecasting electricity demand. Rather than relying exclusively on past consumption data, the model can also incorporate temperature forecasts, time of day, and weekday/weekend indicators. These covariates can meaningfully improve the model’s ability to capture patterns and respond to changes in external conditions.

Implementation in TDgpt

In the illustration above, there are two covariates and one target variable :

  • Target is the variable to be forecast.
  • Predicted value is the forecast result.
  • Past real dynamic features are historical covariates.
  • Real dynamic features are future covariates.

Historical covariate data, as well as future covariate data that span the same time range as the target variable, are fetched from TDengine. However, future covariate values after the time range of the target variable (i.e. corresponding to forecast data) must be manually specified.

Historical Covariate Forecasting

When the FORECAST function in TDgpt is given a single input column, it operates in the default single-variable forecasting mode. When multiple columns are provided, the first column is treated as the target variable, and the subsequent columns are treated as covariates.

Each forecast query allows up to 10 covariate columns as historical inputs. An example SQL statement is shown as follows:

SELECT _frowts, FORECAST(val, past_co_val, 'algo=moirai') FROM foo;

This statement forecasts data from the table foo using the column val as the target and past_co_val as the covariate.

Future Covariate Forecasting

When performing future covariate forecasting, you specify both the future input values and the corresponding covariate columns. These values must be provided in the SQL statement. The number of values must match the number of forecast points.

Future covariates must be named using the prefix dynamic_real_. For each future input variable, you must also define the associated covariate column with the parameter <future-covariate-name>_col, for example the column associated with dynamic_real_1 is specified using the parameter dynamic_real_1_col. An example SQL statement is shown as follows:

SELECT _frowts, FORECAST(val, past_co_val, future_co_val, "algo=moirai,rows=4,dynamic_real_1=[1 1 1 1],dynamic_real_1_col=future_co_val") FROM foo;

In this statement, forecasting is performed on the val column, with one historical covariate column past_co_val and one future co-variate column future_co_val.

  • Four values for the future covariate are provided in the dynamic_real_1 parameter.
  • The association between dynamic_real_1 and the future covariate column future_co_val is established using the parameter dynamic_real_1_col=future_co_val.

Supported Models

At present, you must use the Moirai foundation model for time-series to perform covariate forecasting in TDgpt. Moirai is Salesforce’s universal time-series forecasting foundation model, designed to deliver accurate predictions across a wide range of domains, frequencies, and variable types without requiring retraining. This model is installed in TDgpt by default in version 3.3.6.4 and later.

For more information about TDgpt, see the official documentation.

  • Joel Brass
    Joel Brass

    Joel Brass is a Solutions Architect at TDengine, bringing extensive experience in real-time data processing, time-series analytics, and full-stack development. With a 20 year background in software engineering and a deep focus on scalable applications and solutions, Joel has worked on a range of projects spanning joke databases, IoT, self-driving vehicles, and work management platforms. Prior to joining TDengine, Joel worked in Advisory Services for Enterprise customers of Atlassian and the Systems Engineering team at Waymo. He is currently based in the San Francisco Bay Area.