Skip to main content

Introduction

Pricing decisions significantly impact retail demand. TimeGPT makes it possible to forecast product demand while incorporating price as a key factor, enabling retailers to explore how the forecast changes under different pricing assumptions. This tutorial demonstrates how to use TimeGPT for scenario analysis by forecasting demand under various pricing conditions. You’ll learn to incorporate price data into forecasts and compare forecasts across different price assumptions.
A scenario forecast is not a price-effect estimate. Changing a future price and re-forecasting shows the model’s conditional forecast given that price: a relationship learned from how price and demand moved together historically. In retail history, prices are rarely changed at random: markdowns respond to slow sales, and promotions are timed to seasons. The learned relationship therefore mixes the true effect of price with the pricing policy that set it, so the difference between two scenario forecasts can overstate or understate the real demand response to a price change. This is most pronounced for price moves outside the historically observed range.Use these scenarios to explore and stress-test assumptions, not to read off price elasticities. Before committing a pricing decision, validate the implied demand response with a price experiment or a holdout test.

What You’ll Learn

  • How to forecast retail demand using price as an exogenous variable
  • How to run what-if scenarios with different pricing strategies
  • How to compare baseline, increased, and decreased price forecasts
  • How to interpret scenario forecasts and why they are not price-elasticity estimates

How to Forecast Sales with Pricing Scenarios

Open In Colab

Step 1: Import required packages

Import the packages needed for this tutorial and initialize your Nixtla client:
Initialize the Nixtla client:

Step 2: Load the M5 dataset

Let’s see an example on predicting sales of products of the M5 dataset. The M5 dataset contains daily product demand (sales) for 10 retail stores in the US. First, we load the data using datasetsforecast. This returns:
  • Y_df, containing the sales (y column), for each unique product (unique_id column) at every timestamp (ds column).
  • X_df, containing additional relevant information for each unique product (unique_id column) at every timestamp (ds column).
For this example, we will only keep the additional relevant information from the column sell_price. This column shows the selling price of the product, and we expect demand to fluctuate given a different selling price.

Step 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. Learn more about using exogenous variables in TimeGPT.
Merge the sales (y) and price (sell_price) data into one DataFrame:
Let’s investigate how the demand, our target y, of these products has evolved in the last year of data.
Historical retail demand showing intermittent sales patterns across 10 stores for FOODS_1_129 product

Historical retail demand showing intermittent sales patterns across 10 stores

We see that in the California stores (with a CA_ suffix), the product has sold intermittently, whereas in the other regions (TX and WY) sales where less intermittent. Note that the plot only shows 8 (out of 10) stores. Next, we look at the sell_price of these products across the entire data available.
Historical pricing trends showing approximately 20 price changes from 2011 to 2016 for retail products

Historical pricing trends showing price changes over 5 years for retail products

We find that there have been relatively few price changes (about 20 in total) over the period 2011 to 2016. Let’s turn to our forecasting task. We will forecast the last 28 days in the dataset. To use the sell_price exogenous variable in TimeGPT, we have to add it as future values. Therefore, we create a future values dataframe, that contains the unique_id, the timestamp ds, and sell_price.
Next, we limit our input dataframe to all but the 28 forecast days:
Now, we can generate forecasts using TimeGPT (28 days ahead):
We plot the forecast, the actuals and the last 28 days before the forecast period:
TimeGPT baseline forecast showing actual demand and 28-day ahead predictions for retail products

TimeGPT baseline forecast with 28-day ahead predictions for retail demand

Step 4: What-If Scenario Forecasting with Price Changes

What happens when we change the price of the products in our forecast period? Let’s see how our forecast changes when we increase and decrease the sell_price by 5%.
Let’s create a new set of forecasts with TimeGPT.
Rename and combine the scenario forecasts:
In this run, forecast demand increases when we reduce the price and decreases when we increase it: the direction most retailers would expect. Keep in mind that this reflects the association the model learned from this product’s pricing history; as cautioned above, the size of the gap between the scenarios, and for some products even its direction, should not be read as the causal effect of the price change. Finally, let’s plot the forecasts for our different pricing scenarios, showing how TimeGPT forecasts a different demand when the price of a set of products is changed.
What-if scenario comparison: baseline, +5% price increase, and -5% price decrease demand forecasts

What-if scenario comparison showing demand forecasts under different pricing strategies

In the graphs we can see that for specific products for certain periods the discount increases expected demand, while during other periods and for other products, price change has a smaller effect on total demand.

Conclusion

What-if forecasting with TimeGPT supports pricing discussions by:
  • Exploring how the demand forecast changes under different price assumptions
  • Comparing multiple pricing scenarios simultaneously
  • Incorporating exogenous variables for realistic predictions
Scenario forecasts are a starting point for a pricing conversation, not a substitute for measuring price effects: the differences between scenarios reflect learned associations, and their magnitude and direction can differ from the true demand response. Validate promising scenarios with price experiments or holdout tests before acting on them.

Next Steps

Important Considerations

  • This method assumes that historical demand and price behaviour is predictive of future demand, and omits other factors affecting demand. To include these other factors, use additional exogenous variables that provide the model with more context about the factors influencing demand.
  • Because historical prices were typically set in response to demand rather than at random, the measured relationship between price and demand is an association, not a causal effect. Treat scenario differences as directional input for planning, and rely on experiments or basket-level analysis when you need to know why demand changed.
  • This method is sensitive to unmodelled events that affect the demand, such as sudden market shifts. To include those, use additional exogenous variables indicating such sudden shifts if they have been observed in the past too.