algo-price-elasticity
計算需求價格彈性,評估調價對銷量和營收的影響
中文翻譯
---
name: "algo-price-elasticity"
description: "計算需求價格彈性,量化價格變動如何影響銷量。當使用者需要估算需求敏感度、訂出最佳價格、或評估調價對營收的影響時使用,即使他們說的是「客戶對價格有多敏感」、「漲價會不會影響銷量」或「彈性計算」也一樣。"
metadata:
category: "WP-39 定價演算法"
tags: ["pricing", "elasticity", "demand-analysis", "economics"]
---
# 需求價格彈性(Price Elasticity of Demand)
## 概述
價格彈性衡量價格每變動 1%,需求量變動的百分比。Ed = %ΔQ / %ΔP。|Ed| > 1 = 有彈性(對價格敏感),|Ed| < 1 = 缺乏彈性(對價格不敏感)。對定價決策和營收最佳化至關重要。
## 何時使用
**觸發條件:**
- 要估算調價會如何影響銷售量和營收
- 要判斷某個產品的需求有彈性還是缺乏彈性
- 要把價格最佳化到營收或利潤最大
**何時不要用:**
- 需要的是消費者願付價格的分布時(用 Van Westendorp 或聯合分析)
- 多個產品要一起定價時(用組合包定價)
## 演算法
```
鐵律:在線性需求曲線上,彈性不是常數。每個價格點都不一樣。價格高時需求有彈性(小幅漲價 → 銷量大跌),價格低時需求缺乏彈性。一定要在你關心的「特定價格點」上計算。讓營收最大的價格,就是 Ed = -1(單位彈性)的地方。
```
### 階段 1:輸入驗證
蒐集:隨時間(或跨市場)的價格與數量配對。要控制:季節性、促銷、競爭者動作、其他混淆因子。
**關卡:** 至少 10 筆價格與數量的觀測值、混淆因子已辨識。
### 階段 2:核心演算法
**點彈性:** 在特定價格點上,Ed = (dQ/dP) × (P/Q)
**弧彈性:** 兩點之間,Ed = ((Q₂-Q₁)/((Q₂+Q₁)/2)) / ((P₂-P₁)/((P₂+P₁)/2))
**迴歸法:** log(Q) = α + β×log(P) + controls → β 就是彈性(固定彈性模型)
### 階段 3:驗證
檢查:符號應該是負的(價格上升 → 數量下降)。用 holdout 期間做交叉驗證。
**關卡:** 彈性為負、信賴區間合理。
### 階段 4:輸出
回傳彈性估計,並附上營收影響的推估。
## 輸出格式
```json
{
"elasticity": -1.5,
"interpretation": "elastic — 1% price increase → 1.5% quantity decrease",
"revenue_impact": {"price_change_pct": 10, "quantity_change_pct": -15, "revenue_change_pct": -6.5},
"metadata": {"method": "log-log regression", "r_squared": 0.82, "observations": 52}
}
```
## 範例
### 輸入輸出範例
**輸入:** 價格從 $100 漲 10% 到 $110,數量從 1000 掉到 850
**預期:** 弧彈性 = ((-150/925) / (10/105)) = -1.70(有彈性)
### 邊界情況
| 輸入 | 預期 | 原因 |
|-------|----------|-----|
| 奢侈品 | 可能是正的(Veblen 效應) | 價格越高 → 感知價值越高 |
| 必需品(胰島素) | 接近零 | 需求幾乎不隨價格變動 |
| 有完全替代品 | 非常有彈性(< -3) | 顧客馬上轉換 |
## 常見陷阱
- **遺漏變數偏誤**:沒控制廣告、季節性和競爭者價格的話,彈性估計會有偏誤。
- **短期 vs 長期**:短期彈性通常比較低(顧客被綁住)。長期則給了他們時間去找替代品。
- **交叉價格彈性**:產品 A 的需求可能取決於產品 B 的價格。在產品組合的情境下忽略這點,會讓定價不是最佳。
- **不對稱彈性**:消費者對漲價和降價的反應可能不同。別假設對稱。
- **小樣本雜訊**:觀測值少的時候,彈性估計的信賴區間會很寬。要報區間,不要只報點估計。
## 腳本
| 腳本 | 說明 | 用法 |
|--------|-------------|-------|
| `scripts/arc_elasticity.py` | 計算弧彈性和營收影響 | `python scripts/arc_elasticity.py --help` |
執行 `python scripts/arc_elasticity.py --verify` 可以跑內建的健全性測試。
## 參考資料
- 以迴歸為基礎的彈性估計,見 `references/regression-estimation.md`
- 交叉價格彈性分析,見 `references/cross-price.md`英文原文
---
name: "algo-price-elasticity"
description: "Calculate price elasticity of demand to quantify how price changes affect sales volume. Use this skill when the user needs to estimate demand sensitivity, set optimal prices, or evaluate the revenue impact of price changes — even if they say 'how sensitive are customers to price', 'will a price increase hurt sales', or 'elasticity calculation'."
metadata:
category: "WP-39 定價演算法"
tags: ["pricing", "elasticity", "demand-analysis", "economics"]
---
# Price Elasticity of Demand
## Overview
Price elasticity measures the percentage change in quantity demanded for a 1% change in price. Ed = %ΔQ / %ΔP. |Ed| > 1 = elastic (price-sensitive), |Ed| < 1 = inelastic (price-insensitive). Critical for pricing decisions and revenue optimization.
## When to Use
**Trigger conditions:**
- Estimating how a price change will affect unit sales and revenue
- Determining if demand is elastic or inelastic for a product
- Optimizing price for maximum revenue or profit
**When NOT to use:**
- When you need consumer willingness-to-pay distribution (use Van Westendorp or conjoint)
- When pricing multiple products together (use bundle pricing)
## Algorithm
```
IRON LAW: Elasticity Is NOT Constant Along a Linear Demand Curve
It varies at every price point. At high prices, demand is elastic
(small price increase → big volume drop). At low prices, demand is
inelastic. Always calculate at the SPECIFIC price point of interest.
Revenue-maximizing price is where Ed = -1 (unit elastic).
```
### Phase 1: Input Validation
Collect: price-quantity pairs over time (or across markets). Control for: seasonality, promotions, competitor actions, other confounders.
**Gate:** Minimum 10 price-quantity observations, confounders identified.
### Phase 2: Core Algorithm
**Point elasticity:** Ed = (dQ/dP) × (P/Q) at a specific price point
**Arc elasticity:** Ed = ((Q₂-Q₁)/((Q₂+Q₁)/2)) / ((P₂-P₁)/((P₂+P₁)/2)) between two points
**Regression method:** log(Q) = α + β×log(P) + controls → β is the elasticity (constant elasticity model)
### Phase 3: Verification
Check: sign should be negative (price up → quantity down). Cross-validate with holdout periods.
**Gate:** Elasticity is negative, confidence interval is reasonable.
### Phase 4: Output
Return elasticity estimate with revenue impact projection.
## Output Format
```json
{
"elasticity": -1.5,
"interpretation": "elastic — 1% price increase → 1.5% quantity decrease",
"revenue_impact": {"price_change_pct": 10, "quantity_change_pct": -15, "revenue_change_pct": -6.5},
"metadata": {"method": "log-log regression", "r_squared": 0.82, "observations": 52}
}
```
## Examples
### Sample I/O
**Input:** Price increased 10% from $100 to $110, quantity dropped from 1000 to 850
**Expected:** Arc elasticity = ((-150/925) / (10/105)) = -1.70 (elastic)
### Edge Cases
| Input | Expected | Why |
|-------|----------|-----|
| Luxury good | May be positive (Veblen) | Higher price → higher perceived value |
| Necessity (insulin) | Near zero | Demand barely responds to price |
| Perfect substitute available | Very elastic (< -3) | Customers switch immediately |
## Gotchas
- **Omitted variable bias**: Without controlling for advertising, seasonality, and competitor prices, elasticity estimates are biased.
- **Short-run vs long-run**: Short-run elasticity is typically lower (customers are locked in). Long-run gives them time to find substitutes.
- **Cross-price elasticity**: Demand for product A may depend on product B's price. Ignoring this in a portfolio context leads to suboptimal pricing.
- **Asymmetric elasticity**: Consumers may react differently to price increases vs decreases. Don't assume symmetry.
- **Small sample noise**: With few observations, elasticity estimates have wide confidence intervals. Report intervals, not just point estimates.
## Scripts
| Script | Description | Usage |
|--------|-------------|-------|
| `scripts/arc_elasticity.py` | Compute arc elasticity and revenue impact | `python scripts/arc_elasticity.py --help` |
Run `python scripts/arc_elasticity.py --verify` to execute built-in sanity tests.
## References
- For regression-based elasticity estimation, see `references/regression-estimation.md`
- For cross-price elasticity analysis, see `references/cross-price.md`