Exogenous Variables Tutorial
Learn how to incorporate external variables to improve your forecasting accuracy.
Exogenous variables (external factors) play a key role in time series forecasting. By providing additional context—like holidays, marketing spend, or weather conditions—they can significantly improve your model’s accuracy.
1. Import Packages
Use the following code to import the required libraries and initialize the Nixtla client.
If you’re using an Azure AI endpoint, explicitly define the base_url parameter:
2. Load Dataset
In this tutorial, we’ll predict day-ahead electricity prices. The dataset contains hourly electricity prices (y
) from various markets (identified by unique_id
) along with exogenous variables (Exogenous1
to day_6
).
3a. Forecasting with Future Exogenous Variables
To make a forecast using exogenous variables, you need to provide future exogenous values. Below is an example dataset containing future exogenous variables:
Ensure you maintain consistent data formatting and columns in both historical and future exogenous datasets (e.g., dates, unique_id, variable names).
Important Note on Historical Data Use:
Using historical exogenous variables to predict the future assumes the same patterns will hold. Whenever possible, explicitly forecast these external variables to increase accuracy.
Example Forecast Visualization
Once you have generated your forecasts, you can visualize the results to compare forecasts using provided exogenous variables vs. forecasted ones.
Forecast comparison using provided vs. forecasted exogenous variables
Key Takeaways
- Exogenous variables enrich time series forecasting.
- Ensure proper alignment of historical and future exogenous data.
- Use separate models to forecast exogenous variables if necessary.
Next Steps
- Explore feature engineering to create domain-specific exogenous data.
- Experiment with different modeling approaches for external variables.
- Validate forecast accuracy by comparing with real future data.
Congratulations! You have mastered the fundamentals of adding exogenous variables to your TimeGPT forecasts. Keep refining your approach by incorporating advanced feature engineering and robust data validation.
By following these steps and guidelines, you can seamlessly integrate exogenous variables into your forecasting workflows, unlocking more accurate predictions and deeper insights into the factors driving your time series data.