How much more would it have sold?
The demand hidden behind stockout days. Four layers, from raw sales to scaling by the life cycle curve, and how far each one misses real demand.
Repeat Order (RPT) · 3 / 6
Pelin’s question is short: how much more would this product have sold if there had been more? On the shop floor nobody can check the answer, because the customer who finds the rail empty is never written down anywhere. That is what we call censored demandDemand that arrives while the shelf is empty and is never recorded. Sales data show not demand but the smaller of demand and stock..
We have answered this question on the site once already. The Lost Sales series set out ways of estimating the demand on a stockout day and tested them against the hidden truth; the winner was Simple. The RPT uses the same method. There is one difference, and half of this article is about it: the RPT decision is made on a Monday morning. That morning, all you have is the past.
At Lumoda we know the truth, because the data is synthetic. For every store, every size and every day, real demand = the product’s own sales + unmet demand. Part of the unmet demand is permanent loss, part is a customer who switched to another product. Across the spring-summer season’s Collection products, real demand is 1,641,754 units; 32.6% of it went unmet, and 27.7% of the unmet demand switched to another product. No method sees these numbers; we use them only to mark the exam paper.
What exactly is the question?
On the Monday morning h weeks after launch, using what is known that morning, estimate the product’s total demand from launch to the start of markdown. This number is the input to the RPT quantity sum; the later articles lean on it.
The exam is sat in two of Lumoda’s seasons: autumn-winter and the spring-summer that follows it. Each has 210 Collection options. The product’s own sales are seen only up to that Monday. The life cycle curve and the character of the days, on the other hand, are learnt from seasons that closed before the exam season. In Lumoda’s three years of data there are three closed seasons behind the autumn-winter exam, and four behind the spring-summer one.
The same method, half a window
In the Lost Sales series, Simple builds a stockout day’s demand from the in-stock days on either side of it: two weeks before and two weeks after. Pars explained why there. If the product is slowing down, a sum that looks only backwards overstates demand, and one that looks only forwards understates it. The middle of the two sides is the best witness.
On a Monday morning there is no right-hand side. The estimate is made not after the event but at the moment of the decision, and no row after the decision date can enter the sum. The constraint sits in two places in the code. The pool the estimator learns from is built only from in-stock days before the decision date. And the neighbourhood is cut off one day before the decision date:
high = day + self.neighbour_days
if self._t_day is not None:
high = np.minimum(high, self._t_day - 1)
lo, hi = index.span(group, day - self.neighbour_days, high)
The rest of the method is as in Lost Sales: each in-stock day’s sales are first turned into an ordinary day, then carried over to the stockout day’s conditions. The multipliers that give the days their character also come only from seasons closed by that morning. No sale or stock record after the Monday morning changes the estimate; the case’s tests check this separately.
The adjustment is made not on the chain total but for each store and each size separately, then added up. Adjust the chain total and Erzurum 3’s empty rail gets averaged with Istanbul 18’s full one, and the adjustment shrinks.
Let’s look at the jacket. On the morning of the third Monday the jacket has sold 1,091 units in three weeks. Demand filled in at the decision date is 1,195, 9.5% more. 95.0% of the store and size days opened with stock on the rail; stockouts are still mild. A week later the picture changes: sales of 1,490, filled-in demand of 1,789, 20.1% more. The share of days that opened with stock on the rail has fallen to 89.9%. As a weekly rate, the adjustment is close to the truth on both Mondays: 398.3 against a real 392.7 on the third Monday, 447.2 against 444.0 on the fourth. On this product, half a window does the job.
Four layers
Filled-in demand covers only the first few weeks of the season. How to carry it to the whole season is the second question. The jacket’s real demand from launch to markdown is 3,515 units. Pelin’s plan was 1,985. What the four methods say on the morning of the third Monday:
| Layer | What it does | Estimate |
|---|---|---|
| a | Raw sales: what the report shows | 1,091 |
| b | Rate of filled-in demand × weeks to markdown | 3,984 |
| c | Raw sales ÷ the raw curve’s share (the FRR rule) | 2,624 |
| d | Filled-in demand ÷ the adjusted curve’s share | 3,807 |
a is not an estimate; it is the starting point. By week three the jacket has lived only a third of its season.
b turns filled-in demand into a weekly rate and spreads it at the same rate over every week of the season. Even if the rate is right it goes wrong, because a product slows down as it ages; b does not see this and on average it errs upwards. So it does on the jacket: 3,984 against 3,515.
c is the rule from the literature itself. It is the sum used by the retailer Fisher, Rajaram and Raman studied: divide the first weeks’ sales by how much of their season’s sales similar products saw in their first weeks. The shape is right, but it is censored in two places. Both the numerator and the denominator are censored.
d fixes both of c’s flaws: the numerator is demand filled in at the decision date, the denominator a curve learnt from filled-in demand.
For the jacket, d is close to the truth, a little high: 3,807 against 3,515. On the second Monday it says 3,347, on the sixth 3,436. We will come back to that excess below.
The four layers sit in one function in the code:
k["k_raw"], k["k_adj"] = _k(curve_raw), _k(curve_adj)
W = k["selling_weeks"]
k["a"] = k["x"].astype(float)
k["b"] = k["D"] / h * W
k["c"] = k["x"] / k["k_raw"]
k["d"] = k["D"] / k["k_adj"]
k["a_rate"] = k["x"] / h * W
k["c_adj_curve"] = k["x"] / k["k_adj"]
x is sales up to that morning, D demand filled in at the decision date,
W the number of weeks from launch to markdown. a_rate and c_adj_curve
are two intermediate sums for taking the layers apart: raw rate × weeks, and
raw sales ÷ the adjusted curve. The curve is learnt separately for each
wave, because a product that comes in with the third wave has fewer weeks to
markdown and uses up its curve faster.
The exam results
Error is measured with WAPE: the sum of the absolute errors over all options divided by the sum of real demand. Bias is the same ratio with its sign; minus means under-forecasting. The spring-summer season’s 210 Collection options:
| Layer | h=2 | h=3 | h=4 | h=6 | Bias (h=3) |
|---|---|---|---|---|---|
| a raw sales | 87.3% | 77.1% | 67.6% | 54.9% | −77.1% |
| b filled-in rate × weeks | 19.8% | 23.5% | 31.2% | 30.3% | +13.4% |
| c raw curve (FRR) | 38.8% | 34.9% | 33.0% | 33.6% | −34.7% |
| d filled-in demand ÷ adjusted curve | 22.4% | 20.9% | 20.0% | 14.7% | −9.8% |
| Buyer’s plan | 39.4% | 39.4% | 39.4% | 39.4% | −21.6% |
The autumn-winter season, on the same measures:
| Layer | h=2 | h=3 | h=4 | h=6 | Bias (h=3) |
|---|---|---|---|---|---|
| a raw sales | 85.7% | 75.8% | 66.2% | 50.1% | −75.8% |
| b filled-in rate × weeks | 23.1% | 28.8% | 32.7% | 35.9% | +21.2% |
| c raw curve (FRR) | 32.6% | 31.2% | 29.9% | 27.1% | −30.4% |
| d filled-in demand ÷ adjusted curve | 17.8% | 15.2% | 13.7% | 12.2% | −3.3% |
| Buyer’s plan | 37.6% | 37.6% | 37.6% | 37.6% | −11.4% |
Four things can be read from the tables.
First, the gulf between the plan and the first weeks. The pre-season plan misses by 39.4% in spring-summer. By the end of week two, d misses by 22.4%. In autumn-winter it is 17.8% against 37.6%. Fisher, Rajaram and Raman found 8% against 55% for the same comparison at their retailer. Our gulf is smaller: after two weeks the error falls to a little over half the plan’s, and in autumn-winter to a little under half. But the direction is the same. This gulf is the reason the RPT exists: the initial order is placed with the worst information.
Look at the plan’s bias too: negative in both seasons. Plans fall short of demand on average, and Banu buys a little under the plan as well. The initial order is cautious twice over.
Second, b and c err in opposite directions. b is high because it assumes a flat rate; c is low because it scales with censored data: in week three, +13.4% against −34.7% in spring-summer, +21.2% against −30.4% in autumn-winter. Both are reasonable-looking sums used on the shop floor. Both have systematic errors.
Third, d improves as time passes, but slowly. From week two to week six its error falls from 22.4% to 14.7% in spring-summer, from 17.8% to 12.2% in autumn-winter. Meanwhile the calendar keeps moving. Remember the woven belt Veli mentioned in the first article: from India, made in fourteen weeks. An order placed on the second Monday finds 5.4% of the demand up to markdown when it arrives. One placed on the third Monday, 3.6%. Ahead of one placed on the sixth Monday nothing is left: 0.0%. The race between the forecast getting better and time running out is the RPT itself.
Fourth, d is not first every week. In week two of spring-summer the best of the four layers is b: 19.8% against 22.4%. From week three d moves ahead and the gap widens. In autumn-winter d leads every week, and autumn-winter is the better of the two seasons. d’s bias in spring-summer also stands out: from week two to week six it lies between −17.1% and −5.5%, always negative. In autumn-winter it is close to zero, between −3.5% and +0.9%. The reason, as we will see below, seems to lie largely in the curve.
Censoring distorts the curve too
If the curve is learnt from past seasons’ sales, it is censored too. Hits run out early and their sales stop in their last weeks. That makes the curve look as if it ends earlier than it does: front-loaded.
The adjustment is made with the same method. Past seasons’ stockout days are also filled in with Simple; the decision date is the exam season’s first launch morning. The curve comes not from sales but from filled-in demand, and nothing that happened after that morning enters the curve.
The share of the first three weeks on the spring-summer curve, for the three waves:
| Curve | Wave 1 | Wave 2 | Wave 3 |
|---|---|---|---|
| Learnt from raw sales | 28.7% | 33.7% | 41.6% |
| Learnt from filled-in demand | 22.8% | 25.4% | 31.4% |
| The exam season’s real curve | 18.8% | 19.7% | 33.7% |
Dividing by the raw curve assumes a product has seen a bigger part of its season in three weeks than it has, and so underestimates season demand. Part of layer c’s downward bias comes from here. The adjustment wipes out most of this error: the mean distance to the learning seasons’ own real curve, over the first six weeks, is 7.50 points for the raw curve and 0.38 points for the adjusted one. On the autumn-winter curve, 7.51 against 0.45.
But the table’s last row says something else. The adjusted curve matches the past almost exactly; it does not match the exam season. In spring-summer the products of the first two waves opened more slowly than in past seasons: those in the first wave saw not 22.8% but 18.8% of their season in the first three weeks, those in the second not 25.4% but 19.7%. The adjusted curve’s distance to the exam season’s real curve is 4.39 points in spring-summer and 1.51 points in autumn-winter. The raw curve’s, in spring-summer, is 10.24 points.
d takes its denominator from this curve. When the curve stays more front-loaded than the season’s truth, the denominator grows and d slides down. That is the visible reason for the downward bias in spring-summer. The woven belt is also in the first wave and slides the same way: on the third Monday d says 1,761, the truth is 2,001.
In the third wave the opposite happens. The curve sits slightly behind the truth, 31.4% against 33.7%; d estimates slightly high. Most of the jacket’s excess comes from here. Real demand in the first three weeks was 1,178, and the figure filled in at the decision date 1,195; the demand itself is almost exact, and the curve makes the difference.
You can correct censoring. You cannot correct whether the season will resemble the past.
The curve is learnt by wave. A split by top category × wave was also tried: worse in autumn-winter (5.21 against 4.02 points), slightly better in spring-summer (3.53 against 3.75). The gain is small and changes direction from season to season; wave is enough.
Low on average, both ways on a single product
In spring-summer d stays a little low on average, but look product by product and it scatters both ways: the jacket high, the belt low. The reason is the curve. A product’s season does not have to resemble its wave’s average; a common curve can only carry the average. That does not go away on the shop floor either.
There is also a risk that grows as stockouts grow. Stockouts are more common in hits: in spring-summer, up to the sixth Monday, 84.2% of the store and size days of hits opened with stock on the rail, against 95.7% for misses. The bigger the gap to fill, the more the estimate leans on guesswork. c shows how big this risk can get: the sum that does not see censoring is 42.3% low on hits in week six, which means it makes its biggest mistake on the best-selling product. d largely gets round this risk: in week six, 14.0% on hits and 15.3% on misses.
Both lead to the same conclusion for the RPT: the estimate on its own is not enough; you need its uncertainty too. Saying “season demand is 3,807” is not enough; you have to be able to say how far that number could move. Because the two mistakes in the quantity decision carry different costs, the width of that range changes the size of the order directly. That is the subject of the fifth article.
What is hard in your data
Every table in this article rests on a referee. In your chain there is no referee. You can only see in which season d is low and in which it is unbiased after the season has closed, and even then with another estimate: you fill in the stockout days, this time looking both ways, and compare with the Monday-morning estimate. That is the best test you can run on the shop floor, and it is exactly the label the next article can build in the field. But that test’s answer key is an estimate too.
The second hard thing is what the spring-summer table shows: the curve is learnt from the past, and the season may not resemble the past. You cannot know that in advance. What you can do is put a range next to every number that rests on the curve.
Summary
- The sales report does not show demand. Fill in the stockout days with Lost Sales’ method, at store × size level; but at the decision date, looking only at the past.
- To estimate season demand from the first weeks, take the curve’s shape from the past and its level from this season. Clean the curve of censoring too.
- Done this way, by the end of week two the error falls to a little over half the plan’s in spring-summer and a little under half in autumn-winter. In the weeks that follow the improvement is slow; time, though, runs fast.
- The more the curve resembles the past, the better the estimate. In a season where it does not, the estimate slides one way; that is why a range is needed.
In the next article we use this estimate to go back to the first question: is this product an RPT candidate?