Your Sales Data Is Lying About Demand: Estimating Lost Sales From Stockouts

A product that is out of stock sells zero, and that zero goes into every average and forecast as if nobody wanted it. Here is how to keep stock history in WooCommerce and Magento, estimate demand on stockout days, account for substitution, and stop censored sales from shrinking your forecasts.

Your sales history records what customers bought, not what they wanted. On a day a product is out of stock it sells zero units, and that zero goes into every report, average and forecast as if nobody wanted it. Statisticians call this censored demand: the true number is somewhere above what you observed, and the data cannot tell you how far above.

The cost is large across retail. IHL Group estimates that inventory distortion, the combined cost of out-of-stocks and overstocks, costs the global retail industry $1.73 trillion a year, with about $1.2 trillion of it attributed to out-of-stocks. For a single store the question is more practical: which products lost how much, and is the forecast making it worse?

Two distortions, not one

Researchers studying vending machines described the problem precisely more than 25 years ago: when an item stocks out, its sales are right-censored, while sales of other items are inflated because of substitutions. Both effects matter. The product that ran out looks less popular than it is, and the product customers settled for looks more popular than it is. Reorder both based on raw sales and you get the next stockout and an overstock at the same time.

Observed sales versus estimated demand during a stockout Bar chart of daily unit sales over 14 days. Days 8 to 11 show zero observed sales because the product was out of stock, and day 12 is low because it was restocked mid-afternoon. Outlined bars show the estimated demand on those days, around 12 units each. 051015 Out of stock 1234567891011121314 Day Observed unit sales Estimated demand (not recorded anywhere)
Illustrative. A 14-day average of observed sales here is about 7 units a day. Demand was closer to 11.

What customers do when the product is gone

Not every stockout is a lost sale. The best-known study of shopper reactions, by Daniel Corsten and Thomas Gruen, found that when confronted with an out-of-stock, 26 percent of shoppers switch brands, 31 percent switch stores, 19 percent substitute within the same brand, 15 percent delay the purchase, and 9 percent do not buy at all. That research covered physical stores. Online, switching to another site costs one search, and the split differs: a later study reported that in the U.S., 15 percent of shoppers who hit an online out-of-stock bought elsewhere, while 60 percent bought a substitute from the same merchant.

Shopper responseEffect on the stocked-out productEffect on your store
Buys a substitute from youLost unitRevenue partly kept; substitute’s sales inflated
Waits and buys laterUnit shifted to a later dateKept, if they come back
Buys from a competitorLost unitLost sale, possibly a lost customer
Does not buy at allLost unitLost sale

Those published splits are useful as a starting assumption. Your own substitution rate can be measured, and the method below shows how.

Step 1. Start keeping stock history

You cannot estimate lost sales without knowing when a product was out of stock, and neither WooCommerce nor Magento keeps that history by default. Both store the current quantity. WooCommerce exposes it in the wp_wc_product_meta_lookup table; Magento in cataloginventory_stock_item, or inventory_source_item with multi-source inventory. A scheduled job that copies the current values into a snapshot table once a day (or every hour for fast sellers) is enough:

-- WooCommerce: run daily, or hourly for fast movers
INSERT INTO stock_snapshot (snapshot_at, product_id, stock_quantity, stock_status)
SELECT NOW(), product_id, stock_quantity, stock_status
FROM wp_wc_product_meta_lookup;

Until that history accumulates, you can approximate stockout days from the order log: a product that normally sells every day and then records several consecutive zero days is probably out, not unpopular. Treat that inference as provisional.

Step 2. Estimate demand on stockout days

There is a ladder of methods. Most stores get most of the value from the first two rungs.

MethodHow it worksWhen it is enough
1. ExcludeDrop stockout days when computing averages and velocityAlways; this alone removes the downward bias
2. Impute from in-stock daysReplace each stockout day with the average of the same weekday over recent in-stock weeks, scaled by trendSteady sellers, short stockouts
3. Partial-day adjustmentFor days out of stock part of the time, scale by the share of normal daily sales that usually happen during the in-stock hoursFast sellers that run out mid-day
4. Substitution adjustmentSubtract the extra units that similar products sold during the stockoutProducts with close substitutes in your catalog
5. Censored demand modelsStatistical models that treat stockout days as “at least this many”, such as Tobit regressionLarge catalogs, frequent stockouts, a forecasting team

For rung 4, compare the sales of the closest alternatives (same category, similar price) during the stockout with their usual rate. The difference is substituted demand. It is revenue you kept, so subtract it from the lost-sales estimate. It is also demand that did not belong to the substitutes, so remove it from their history before forecasting them.

A worked example

A hypothetical product sells for $40 and normally sells about 12 units a day. It was out of stock for four full days and for the last 6 hours of a fifth day, during which half of its usual daily sales typically happen.

Stockout exposure4 full days + 0.5 of a day = 4.5 day-equivalents
Expected unit demand during stockout4.5 x 12 = 54 units
Demand at full price54 x $40 = $2,160
Measured substitution into similar products35% of that value
Estimated net lost revenue$2,160 x 0.65 = $1,404

Repeat this across the catalog each month and rank products by net lost revenue. The top of that list is usually short, and it is a much better reorder priority list than “units sold last month”.

Why this breaks forecasts, and how the loop closes

A forecast trained on censored sales learns that demand is lower than it is. The next purchase order is smaller, the product runs out sooner, and the next round of data is more censored still. The authors of a recent stockout-annotated retail dataset describe exactly this self-reinforcing cycle, in which models trained on censored sales underestimate true demand. Seasonal models are affected too: a stockout during last year’s peak teaches the model that the peak was smaller.

The fix is to forecast from the corrected series, not the raw one. Feed the imputed demand from Step 2 into whatever forecasting method you use. QuantumLayers explains how its Holt-Winters and SARIMA forecasts decompose trend and seasonality in How QuantumLayers Forecasts Time Series; those methods produce better forecasts when the input reflects demand rather than availability.

Signals of demand you are already collecting

  • Product page views while out of stock. GA4 view_item events on a sold-out page, divided by the product’s normal view-to-purchase rate, give a second independent estimate of missed units.
  • Back-in-stock requests. Waitlist sign-ups are a floor on demand and a list of customers to contact first when stock arrives.
  • Site search for the product name. Searches that end on a sold-out result are demand you can count.

When the order-based estimate, the page-view estimate and the waitlist all point the same way, you can trust the number enough to change a reorder quantity. When they disagree, look at whether a substitute absorbed the demand.

Sources