What-If Forecasting: Price Effects in Retail
Learn how to use TimeGPT to forecast sales scenarios with different pricing strategies.
TimeGPT makes it possible to forecast product demand in the retail sector and evaluate how different pricing scenarios might affect demand. Scenario analysis offers valuable insights for informed decision-making.
Forecast product demand using price as an exogenous variable
Evaluate different pricing scenarios
1. Import required packages
Import the packages needed for this tutorial and initialize your Nixtla client:
If you are using Nixtla’s standard endpoint, simply provide your API key:
If you are using Nixtla’s standard endpoint, simply provide your API key:
If you have an Azure AI endpoint, configure the base_url
argument accordingly:
2. Load the M5 dataset
We will use the M5 dataset, containing product sales data from 10 US retail stores. The data includes:
DataFrame | Contents |
---|---|
Y_df | Historical sales (y ) for each product (unique_id ) and date (ds ). |
X_df | Additional information (exogenous variables) such as sell_price . |
For a full tutorial on incorporating exogenous variables with TimeGPT, please see the dedicated documentation.
Because we want price-driven demand forecasts, we’ll focus on the sell_price
column:
3. Forecast demand using price as an exogenous variable
In this example, we forecast for a single product (FOODS_1_129_
) across all 10 stores. This product exhibits frequent price changes, making it ideal for modeling price effects on demand.
Merge the sales (y
) and price (sell_price
) data into one DataFrame:
Check the historical demand and pricing trends:
Now, split the data into:
• Training data (df_train
)
• Future exogenous data (future_ex_vars_df
)
Generate forecasts using TimeGPT (28 days ahead):
When using Azure AI endpoints, specify model="azureai"
in the forecast
call. Refer to the official tutorials for more details.
Finally, visualize your baseline forecast:
4. 'What if?' forecasting: exploring price changes
We’ll now explore ±5% price changes and their impact on demand. Adjust future prices, forecast demand, and compare to the baseline:
Rename and combine the scenario forecasts:
Visualize all three forecasts (baseline, +5%, and –5%):
What is Price Elasticity?
What is Price Elasticity?
Price elasticity measures demand sensitivity to price changes. For more details, see this Wikipedia article.
Important Considerations
Important Considerations
-
Forecasting relies on historical patterns, which may not capture entirely new market conditions.
-
Include additional exogenous variables if you expect them to significantly impact sales.
-
If historical data capture major market shifts, explicitly model them for better accuracy.