One-line: A naive sales-vs-price regression tells this retailer to raise prices everywhere. Corrected for product mix, the truth is the opposite — and that gap is the whole point of the project.
Answer a question every business owner asks: "How much can I raise prices before I lose customers?" — and show why the intuitive way of answering it is dangerously wrong.
Retail Price Optimization (Kaggle, derived from the Brazilian Olist e-commerce dataset). A monthly panel of 48 products across 7 categories (617 clean rows), with unit price, quantity sold, a competitor price and the calendar month. 100% public data.
Price elasticity = the % change in quantity sold for a +1% change in price. It is read
directly from the slope of a log-log regression: ln(qty) = β₀ + β₁·ln(price) + …,
where β₁ is the elasticity.
- Naive model — one regression per category, controlling for competitor price and seasonality.
- Corrected model — the same, plus product fixed effects
C(product_id), so elasticity is measured within the same product over time rather than across different products. This removes the mix bias described below.
The naive model recommends raising prices on all 7 categories — several categories even show a positive elasticity, i.e. "raise the price and you'll sell more." That is economically impossible. It happens because the model compares different products: an expensive product often sells well because it's a better product, not because the high price drives demand. The regression confuses "this product is premium" with "this product got more expensive."
Add product fixed effects and the picture flips:
| Category | Naive | Corrected | +10% price → revenue |
|---|---|---|---|
| furniture_decor | +0.14 | −6.0 | −38% |
| bed_bath_table | +0.50 | −3.8 | −24% |
| computers_accessories | +0.82 | −3.0 | −18% |
| watches_gifts | +0.11 | −2.8 | −16% |
Four categories move from an absurd positive elasticity to a strongly negative one. All four significant categories are highly price-elastic (|e| > 1): raising prices there destroys revenue. Not one category shows real pricing power.
A casual price-vs-sales analysis doesn't just give a fuzzy answer — it can point you the exact wrong way, telling you to raise prices on demand that is in fact highly price-sensitive. Measuring elasticity correctly requires isolating the price effect from everything else that makes a product sell.
- With product fixed effects, the price variation that identifies elasticity is mostly promotions (a product's price moving over time ≈ discounts). So these are closer to promotional elasticities — naturally large — than to structural list-price elasticities. The direction is robust; the exact magnitudes are not.
- Small panel (48 products) → wide confidence intervals; 3 of 7 categories are not significant and are shown in grey.
- Observational data. The gold standard would be an experiment (randomized price tests) or an instrumental variable (a cost shock) — out of scope for a 1.5-day build.
analyse.py— cleaning + EDA →figures/01_eda_prix_volume.pngelasticite.py— naive vs fixed-effects model + pricing simulation → figures 02 & 03reports/elasticites.csv— full results
pip install -r requirements.txt
python analyse.py
python elasticite.py

