I’m Changing the Past
A data-driven approach for swapping what happened with what should have happened
You can’t change the past.
But you can reimagine it.
What would’ve happened if things had gone differently?
What if a product hadn’t stocked out? What if a customer had seen the right recommendation?
What if… what if…. what if…
Most people say these questions are pointless.
They’re not.
Take your local Target store. They forecast demand using past sales. This makes sense. But when a product stocks out, it sells zero. And that zero? It gets recorded as demand.
But was demand really zero?
Maybe.
Maybe not.
Maybe you were standing in the aisle looking at the empty shelf with disappointment.
That out-of-stock wasn’t just a blip. It was a constraint baked into history.
And if you model from that, you’re bringing that constraint to life.
To break the cycle, you have to do something generally unadvised:
You have to reimagine the past.
How to Fake the Past (on Purpose)
Start with sales data. Then, add out-of-stock flags. Being OOS is the constraint you’re going to undo.
Not only do we have days of 0 sales, we created that artificial ceiling at 60 units. That cap wasn’t demand, it was a physical limit.
Next, we generate a version of true demand. This is an estimate of what would’ve happened without stockouts.
Technically, it’s an AR(2) time series with a seasonal pattern1.
Visually? It smooths over the gaps. It shows the world as it should have been.
Why the gap between sales and true demand?
Blame shelf space. Blame restocking cycles. Physical constraints show up as zeros in your data.
We know we lost sales. So should we forecast based on that constrained reality?
Hell no.
Forecast what happened, and you get more stockouts.
Forecast what should have happened, and you actually plan for demand.
The difference isn’t subtle, it’s money.
Even if you're cautious about overstocking, forecasting on true demand still points to higher inventory levels than the sales data suggests.
Because sales data reflects constraints. Not actual need.
Forecast using sales data, and you’re locking in future stockouts => guaranteed.
But forecast true demand, and now you’ve got options: increase shelf space, order more product, and actually meet what customers want.
Conclusion
We make decisions based on our expectations of the future. But if we’re not intentional, those expectations get shaped by past constraints.
Don’t let that happen.
What if you had more shelf space? You’d meet the real demand.
In the long run, most constraints are flexible. Just don’t make the mistake of treating them like they’re not.
To do this, we make some assumptions; product is OOS 10% of the time and there is a max inventory level. For all the details, and all the code, see this article: https://juanitorduz.github.io/demand/