美國 CPI 貢獻度:計算方法
本頁說明儀表板與細項頁上每個數字的來源與公式:資料、權重(relative importance)、月增率與年增率的貢獻度、residual、細項的異常標記,以及驗證結果。
1. 目標與名詞
我們要回答:「CPI 年增率(或月增率)是多少,其中各細項各貢獻了幾個百分點?」細項的貢獻度取決於兩件事:它在消費籃子裡佔多大(權重),以及它漲了多少。
| 符號 | 意義 |
| \(I_i(t)\) | 細項 \(i\) 在第 \(t\) 月的 CPI-U 指數(all items 記為 \(I_{\text{all}}\)) |
| \(RI_i(t)\) | 相對重要性:細項 \(i\) 在 \(t\) 月占整體支出的比重(%)。全部互斥細項加總為 100 |
| \(c_i(t)\) | 貢獻度,單位為百分點(pp)。各項加總 ≈ 總體變動率 |
| 權重年 \(y\) | 使用同一組支出權重的期間:\(y\) 年 1 月到 12 月 |
| 錨點 \(a_y\) | 權重年 \(y\) 的起點,也就是 \(y-1\) 年 12 月 |
2. 資料來源
2.1 指數
全部來自美國勞工統計局(BLS)Public Data API,美國城市平均 CPI-U。月增率用季調序列(CUSR0000+細項代碼),年增率用未季調序列(CUUR0000+細項代碼),和 BLS 新聞稿與 Bloomberg 的慣例一致。
2.2 權重
BLS 每年公布一張「Relative importance of components in the Consumer Price Indexes: U.S. city average, December」表(Table 1),列出全美城市平均、所有細項在 12 月的相對重要性。本專案解析了 1987–2025 年共 47 張(含舊權重版)。各年細項代碼不一致(例如 Food 在 1987 年是 SA11),因此一律以細項名稱比對。2010 年以前的表沒有 Energy services 這一列,以 Energy − Energy commodities 推得。
新一年的 12 月表由 BLS 在 1 月隨權重更新一起公布。
3. CPI 如何加總
CPI 是修正型 Laspeyres(Lowe)指數:固定一籃子數量,用當期價格重新計價。把指數表示成相對於錨點 \(a\) 的比值時,整體等於各互斥細項價格變動的加權平均,權重就是錨點當月的支出比重:
$$\frac{I_{\text{all}}(t)}{I_{\text{all}}(a)} \;=\; \sum_i s_i(a)\,\frac{I_i(t)}{I_i(a)}, \qquad \sum_i s_i(a)=1 \tag{1}$$
其中 \(s_i(a)=RI_i(a)/100\)。式 (1) 在同一個權重年度內對任何互斥且窮盡的細項組合都精確成立(只差指數四捨五入)。跨過權重更新時不成立,這是第 8 節 residual 的主要來源。
BLS 更換支出權重的歷史(權重年 → 支出資料期間):
2002–2022 年每兩年更新一次,2023 年起每年更新。即使支出資料沒換,每年 12 月仍是新權重年的錨點。
4. 支出權重與相對重要性
「權重」這個詞在 CPI 裡其實指兩個不同的東西:支出權重決定籃子裡放什麼、放多少;相對重要性是這個籃子在某個月、以那個月的價格計算時,各細項佔總成本的比例。兩者都在回答「這個細項在 CPI 裡佔多大」,差別在於用哪個時間點的價格來衡量。貢獻度要用的是後者。
4.1 兩個名詞
支出權重:例如 2026 年的 CPI 用的是「2024 weights」,也就是 2024 年美國家庭花在各細項上的金額。用這些金額除以當時的價格,等於固定了每樣東西的數量;之後整個權重年度都用這個數量固定的籃子。這就是第 3 節說的 Laspeyres(Lowe)指數:籃子內容不變,只有價格在變。
相對重要性:數量固定,但每個月價格都在變。把同一個籃子用當月價格重新計價,各細項佔總成本的百分比就是 RI。某項漲得比平均快,它的 RI 就上升,雖然買的量完全沒變。
4.2 從支出權重到相對重要性
設 \(b\) 是支出參考期間(例如 2024 年),\(E_i(b)\) 是當時花在細項 \(i\) 的金額,\(P_i\) 是價格。隱含的數量是 \(q_i = E_i(b)/P_i(b)\),同一個籃子在 \(t\) 月價格下的成本是:
$$C_i(t) \;=\; q_i\,P_i(t) \;=\; E_i(b)\cdot\frac{P_i(t)}{P_i(b)} \;=\; E_i(b)\cdot\frac{I_i(t)}{I_i(b)}$$
\(C_i(t)\) 就是 BLS 所稱的 cost weight(成本權重),以金額表示。相對重要性是把它換成百分比:
$$RI_i(t) \;=\; \frac{C_i(t)}{\sum_j C_j(t)}\times 100$$
所以 cost weights 和 RI 只是同一件事的兩種單位;這也是本專案不另外使用 cost weights 的原因(見第 2.2 節)。實務上 BLS 是在「細項 × 地區」的層級做這件事,再加總成全美城市平均;CPI-U 與 CPI-W 的消費族群不同,RI 也不同(例如 2025 年 12 月食物:CPI-U 13.698、CPI-W 14.889)。本專案一律使用 CPI-U。
兩個月份 \(a\)、\(t\) 相比:籃子數量固定,所以總成本的變化就是整體指數的變化,\(\sum_j C_j(t)/\sum_j C_j(a) = I_{\text{all}}(t)/I_{\text{all}}(a)\)。代入上式就得到第 4.5 節的價格更新式 (2):
$$\frac{RI_i(t)}{RI_i(a)} \;=\; \frac{C_i(t)/C_i(a)}{\sum_j C_j(t)/\sum_j C_j(a)} \;=\; \frac{I_i(t)/I_i(a)}{I_{\text{all}}(t)/I_{\text{all}}(a)}$$
也就是說,只要知道某個月的 RI 和之後的指數,就能推出之後任何一個月的 RI,不需要知道支出金額本身。
4.3 數字例子
以下是為了說明而簡化的虛構數字,只有三個細項。
2024 年家庭支出:食物 $1,400、汽油 $400、其他 $8,200,共 $10,000。到 2025 年 12 月,食物漲 3%、汽油漲 20%、其他漲 4%。同一個籃子在 2025 年 12 月的成本與佔比:
汽油的佔比從 4.00% 升到 4.59%,但家庭買的汽油數量沒有變,變的只是它的相對價格。
再往下走一個月:假設 2026 年 1 月汽油再漲 10%,其他價格不變。
整體 CPI 月增率是 \(10{,}498/10{,}450-1 = 0.459\%\)。用基期(12 月)的 RI 算出的貢獻度,加總剛好等於 0.459;如果誤用 2024 年的支出權重,只得到 0.400,會低估漲最多的項目,而且加不回總體。同時可以看到 1 月的 RI 又變了(汽油 5.03%),它會是 2 月貢獻度的權重。
4.4 BLS 表格的標題怎麼讀
BLS 的年度表標題像這樣:Table 1 (2024 Weights). Relative importance of components … December 2025。拆開來看:
- 2024 Weights:支出參考期間,也就是籃子內容來自 2024 年的消費。
- December 2025:這個籃子用 2025 年 12 月的價格計價後的佔比。
- 這張表是權重年 2026 的錨點:2026 年每個月的 RI 都從它用式 (2) 推出來。
時間線:2024 年的消費被調查 → 用價格變動更新到 2025 年 12 月 → 從 2026 年 1 月起使用。支出資料比使用年份早兩年,是因為調查資料需要時間整理。各權重年對應的支出期間見第 3 節的表。
4.5 年度內逐月更新
由第 4.2 節的推導,從錨點 \(a\) 到 \(t\) 月:
$$RI_i(t) \;=\; RI_i(a)\cdot\frac{I_i(t)/I_i(a)}{I_{\text{all}}(t)/I_{\text{all}}(a)} \tag{2}$$
這是 BLS 標準的價格更新公式。把式 (2) 對所有細項加總,由式 (1) 可知結果仍是 100。本專案用這個公式從每年 12 月的官方錨點算出每個月的 RI,並與 BLS 每月新聞稿公布的值比對,結果完全相同(第 10.4 節)。
4.6 12 月有兩套權重
每年 12 月同時有兩組相對重要性:
- 舊基礎 \(RI_i^{\text{old}}(\text{Dec } y)\):權重年 \(y\) 的籃子,用式 (2) 更新到 12 月。
- 新基礎 \(RI_i^{\text{new}}(\text{Dec } y)\):換成新支出權重後的籃子在 12 月價格下的佔比,也就是權重年 \(y+1\) 的錨點。BLS 每年公布的 12 月表就是這一組。
兩者的差別純粹來自籃子內容(支出權重)的更換,價格是同一個月的。貢獻度永遠使用基期的權重。12 月當基期時(隔年 1 月的月增率、隔年 12 月的年增率),價格變動發生在權重年 \(y+1\) 內,所以要用新基礎。本專案把每年 12 月的 \(RI\) 一律設為新基礎;少了這一步,12 月的貢獻度就加不起來。
4.7 常見誤解
- 「權重一年只變一次。」只有支出權重(籃子內容)是這樣;相對重要性每個月都在變。
- 「某項 RI 上升,代表大家買得更多。」在同一個權重年度內,數量是固定的;RI 上升只代表它的價格漲得比平均快。消費數量的改變只會在權重更新時反映。
- 「貢獻度可以用支出權重算。」不行。要用基期當月的 RI,否則會像第 4.3 節的例子一樣低估漲幅大的項目,而且加不回總體。
- 「RI 不能相加。」同一個月、同一個指數族群(例如都是 CPI-U)、彼此互斥的細項,RI 可以直接相加,例如食物+能源+核心商品+核心服務=100;本專案用加減組出「核心服務不含住宅」也是靠這一點。不能相加的情況是:不同月份的 RI、CPI-U 與 CPI-W 混用、和支出權重混用,或是有重疊的細項(例如 Food 與 Food at home)。
- 「cost weights 提供了 RI 以外的資訊。」它只是把 RI 換成金額(全體成本權重 × RI),資訊相同。
5. 錨點權重從哪來
5.1 官方表(預設)
權重年 \(y\) 的錨點直接取 BLS 的 \(y-1\) 年 12 月表。對每一組「母項 → 子項」,子項在母項內的比重為:
$$s_{i\mid P}(a_y) \;=\; \frac{\widetilde{RI}_i}{\sum_{j\in P}\widetilde{RI}_j}$$
\(\widetilde{RI}\) 是官方表上四捨五入到小數三位的數值。用子項加總(而不是母項本身)當分母,可以吸收四捨五入造成的 ±0.001pp 缺口,讓子項加總剛好等於母項。
5.2 從指數反推(備援)
沒有官方表的年份才使用(例如新一年的 12 月表還沒公布)。式 (1) 對未知的 \(s_i\) 是線性的:令 \(x_{i,t}=I_i(t)/I_i(a)\)、\(b_t=I_P(t)/I_P(a)\),一年最多 12 條方程式,解一個帶約束的最小平方:
$$\min_{s}\ \sum_{t}\Big(\sum_i s_i\,x_{i,t}-b_t\Big)^2 \quad \text{s.t.}\ \sum_i s_i = 1$$
作法是用 \(s_n = 1-\sum_{i\lt n}s_i\) 消去最後一個未知數,變成一般的最小平方問題:
$$\sum_{i\lt n} s_i\,(x_{i,t}-x_{n,t}) \;=\; b_t - x_{n,t}$$
觀測月數少於未知數時(例如只有 1 月資料),先沿用前一年的錨點比重。
精度限制。2007 年 1 月以前,BLS 指數只公布到小數一位,式 (1) 的殘差從約 \(3\times10^{-6}\) 升到約 \(5\times10^{-4}\)。加上一年內各子項的價格變動高度共線,食物和服務的比重會分不清楚。反推值在 2007 年以後與官方差距多在 ±0.05pp 內,2006 年以前可達 1–4pp。所以反推只當備援,同時也用來檢查官方表解析得對不對(見第 10 節)。
6. 細項層級與組合
權重由以下幾組「互斥且窮盡」的母項 → 子項關係逐層算出:子項權重 = 母項權重 × 子項在母項內的比重。
權重和貢獻度都是線性的,所以可以做加減。「核心服務(不含住宅)」就是這樣組出來的:
$$\text{核心服務不含住宅} \;=\; \underbrace{(\text{Services}-\text{Energy services})}_{\text{核心服務}}-\text{Rent of shelter} \;=\; \text{Services less rent of shelter}-\text{Energy services}$$
7. 貢獻度公式
以下 \(RI\) 以 % 表示,貢獻度的單位是百分點。
7.1 月增率(季調)
$$c_i^{\text{MoM}}(t) \;=\; RI_i(t-1)\cdot\left(\frac{I^{SA}_i(t)}{I^{SA}_i(t-1)}-1\right)$$
7.2 年增率(未季調,標準)
$$c_i^{\text{YoY}}(t) \;=\; RI_i(t-12)\cdot\left(\frac{I_i(t)}{I_i(t-12)}-1\right)$$
這是 Bloomberg WMA 的作法,也是儀表板的預設。
7.3 組合細項
組合細項 \(C=\sum_k \sigma_k\,k\)(\(\sigma_k=\pm1\))的權重與貢獻度都是各節點的帶號加總:\(RI_C=\sum_k\sigma_k RI_k\),\(c_C=\sum_k\sigma_k c_k\)。
8. Residual 與「精確加總」
8.1 Residual 是什麼
$$r(t) \;=\; \underbrace{\left(\frac{I_{\text{all}}(t)}{I_{\text{all}}(t-h)}-1\right)\times 100}_{\text{公布的總體變動率}} \;-\; \sum_i c_i(t)$$
也就是「各項貢獻加總」和「公布的總體漲幅」的差。例如 2026 年 3 月:3.256 − (0.366 + 0.791 + 0.229 + 1.847) = 0.023。它有三個來源:
- 年增率跨過權重更新(主因)。式 (1) 只在同一權重年度內成立。基期 \(t-12\) 與 \(t\) 分屬兩個權重年時,用基期權重乘各項漲幅就加不回總體。反例可以驗證:12 月年增率的基期正好是上一年 12 月的新基礎,整段都在同一權重年內,所以 residual 為 0(資料中 2025-12 為 0.000)。
- 四捨五入。BLS 指數公布到小數三位(2007 年前只到一位),官方權重也只有三位小數。
- 季節調整(只影響月增率)。各序列的季節因子分別估計,季調後的總體不會剛好等於季調後細項的加權和,量級約 0.001pp。
8.2 精確加總(鏈式分解)
按下儀表板的「精確加總」後,年增率改成逐月串接。先算每一步(相鄰兩個有資料的月份 \(p\to m\),未季調)的貢獻,並把該步極小的 residual 依權重比例分攤:
$$c_i^{(1)}(m) = RI_i(p)\left(\frac{I_i(m)}{I_i(p)}-1\right) + r^{(1)}(m)\cdot\frac{|RI_i(p)|}{\sum_j |RI_j(p)|}$$
設 \(g_k\) 為第 \(k\) 步的總體變動率(依時間順序 \(k=1,\dots,K\),從基期之後第一個月到 \(t\))。由伸縮級數恆等式:
$$\prod_{k=1}^{K}(1+g_k)-1 \;=\; \sum_{k=1}^{K} g_k\prod_{j\lt k}(1+g_j)$$
每一步的 \(g_k\) 都能精確拆成 \(\sum_i c_i^{(1)}\),所以:
$$c_i^{\text{YoY, exact}}(t) \;=\; \sum_{k=1}^{K} c_i^{(1)}(k)\prod_{j\lt k}(1+g_j)$$
各項加總剛好等於公布的年增率,而且每一步都落在同一個權重年度內,不受一月換權重影響。意義上,早期月份的貢獻會隨之後的總體漲幅一起複利放大。月增率的精確加總模式,則是把季調 residual 依權重比例分攤。
9. 缺漏月份
2025 年 10 月因聯邦政府停擺,BLS 沒有公布 CPI。所有計算只串接「有資料的月份」:
- 2025 年 11 月的月增率是 9 月到 11 月的兩個月變動(圖上該柱底部有橘線)。
- 年增率仍是完整 12 個月的變動;鏈式分解只少了一段串接。
- 2026 年 10 月的年增率沒有基期指數,屆時依 BLS 的處理方式調整。
10. 驗證
10.1 與 Bloomberg WMA 比對(2026 年 3 月年增率,pp)
2026 年 7 月月增率(0.074 / 0.215 / 0.011 / −0.110 / 0.037 / 0.137)逐項相同。
10.2 反推權重 vs 官方權重
12 月四大類權重的差距:2007 年後多在 ±0.05pp 內(2011 年 0.35pp 例外),2006 年以前 1–4pp。逐年明細見 data/ri_official_vs_estimated.csv。
10.3 價格更新式 (2)
把官方 12 月表用式 (2) 滾動一年,和 BLS 同月的「舊權重版」表比較:2021 年起誤差 ≤ 0.001pp,更早 ≤ 0.02pp。
10.4 與新聞稿的每月權重比對
每月 CPI 新聞稿的 Table 1 會列出上個月的相對重要性。以 2026 年 8 月新聞稿(列的是 7 月權重)為例,本專案用 12 月錨點加式 (2) 逐月滾出來的 7 月權重,與 BLS 公布值完全相同:
10.5 與舊金山聯準銀行(SF Fed)比較
舊金山聯準銀行每月發布 CPI Inflation Contributions from Goods and Services,同樣把 CPI 年增率(未季調)與月增率(季調)拆成食物、能源、核心商品、核心服務不含住宅、住宅五類,並提供 Excel 下載。用本專案的七細項組成相同的五類,與其 1999 年 1 月至 2026 年 8 月共 331 個月的資料比較(單位 pp,SF Fed 只到小數第二位):
差異主要來自「住宅」的定義:SF Fed 的 Shelter 對應 BLS 的 Shelter(SAH1),本專案用的是 Rent of shelter(SAS2RS)。兩者之差剛好就是「租屋與住宅保險」(Tenants' and household insurance)一項:2025 年 12 月的權重為 35.625 − 35.333 = 0.292,這一項在本專案被歸入「核心服務不含住宅」。其餘差異來自四捨五入,以及七細項是由不同細項組合而成、各自保留 residual。SF Fed 另外提供核心 CPI 月增率的 67 個細項貢獻,是本專案目前沒有的更細拆分。
11. 細項頁
細項頁把 CPI 沿 BLS 的支出類別階層一路拆到 level 5,讓你看到某個月是哪些細項推升或拉低了通膨,並標出漲幅異常的細項。計算方法與主頁相同,只是逐一套用到每個細項。
11.1 範圍與資料
- 細項:以最新一年 12 月官方權重表的支出類別階層為準,level 1(八大類)到 level 5,共 239 項,其中最底層 166 項。最底層彼此互斥,權重加總約為 100。
- 最底層不一定在 level 5:有些細項在較淺的層級就沒有再往下拆,它們本身就是最底層。
- 階層修正:BLS Excel 表裡有少數列的縮排標錯(例如「酒精飲料」被標到「食物」底下),程式會用「母項權重 = 子項權重加總」自動偵測並修正。
- 指數:來自 BLS 整批資料檔(download.bls.gov),全美城市平均的 CPI-U,季調與未季調。
- 月份:可選最近 10 年;細項漲幅的歷史從 2006 年起,供異常比較使用。
11.2 權重與貢獻
與第 4、7 節相同,逐項套用:
- 12 月錨點:每年 12 月官方表中該細項的相對重要性(新基礎)。細項依名稱對應;BLS 改過名稱的細項,會用舊名稱對應舊年份的表(例如 Airline fares 在 2014–2016 年的表格裡叫 Airline fare)。
- 年度內:用式 (2) 逐月更新。
- 月增率貢獻:\(RI_i(p)\cdot\big(I_i(t)/I_i(p)-1\big)\),\(p\) 是上一個有公布的月份。有季調指數就用季調,沒有就用未季調(頁面標「NSA」)。最底層約 34 項、合計約 11% 權重沒有季調指數,例如行動電話服務、健康保險;這是 BLS 的做法,沒有明顯季節性的序列不做季調。
- 年增率貢獻:\(RI_i(t-12)\cdot\big(I_i(t)/I_i(t-12)-1\big)\),未季調。
11.3 BLS 沒有公布指數的細項
- 未抽樣項目與少數沒有全美指數的細項(23 項,合計約 2% 權重,其中「第二住所的自有住宅設算租金」單獨約 1.2%):BLS 有權重但不公布指數。本專案用最近一個有指數的上層細項的漲幅來估計,頁面標「估」。BLS 自己計算時,這類項目也是由上一層的變動補值。
- 某些月份沒有公布的細項(樣本不足時 BLS 不公布):推算權重時,暫時讓它跟著上層細項變動;它自己那個月的漲幅和貢獻顯示「無資料」,不另外估計。
11.4 未分配
$$\text{未分配}(t) \;=\; \text{總體變動率}(t) \;-\; \sum_{i\in\text{最底層}} c_i(t)$$
來源與第 8.1 節的 residual 相同(年增率跨過權重更新、四捨五入、季節調整),再加上當月 BLS 沒公布的細項。拆得越細,年增率跨過權重更新的效應越明顯。2016-09 至 2026-08:月增率平均 0.019pp、最大 0.077pp;年增率平均 0.079pp、最大 0.28pp。
11.5 異常標記
比較的是細項自己的漲幅,不是貢獻度(權重大的細項貢獻天生就大,用貢獻比會一直標出同一批細項)。對所選月份 \(t\),取同一細項在 \(t\) 之前 120 個月的同類漲幅(月增率比月增率、年增率比年增率)\(g_{t-120},\dots,g_{t-1}\),至少要有 36 個觀測值:
$$z_t \;=\; \frac{g_t-\bar g}{s_g}, \qquad \text{百分位}_t \;=\; 100\times\frac{\#\{g_j < g_t\}}{\#\{g_j\}}$$
\(\bar g\)、\(s_g\) 是這 120 個月的平均與標準差。\(|z_t|\ge 2\) 時標 ▲(異常高)或 ▼(異常低)。排行和表格的預設排序仍然依貢獻度。細項歷史圖中的灰色區塊,就是 \(\bar g \pm 2 s_g\)(右軸)。
11.6 深度與「只看核心」
- 深度 \(d\):排行使用「level 等於 \(d\) 的細項,加上比 \(d\) 淺但已經沒有子項的細項」,這樣任何深度下的細項都互斥且涵蓋全部。「最底層」則是 166 個最底層細項。
- 核心:不在「食物」、「家庭能源」、「汽車燃料」底下的細項,與 BLS 的「All items less food and energy」一致。
- 同時包含核心與非核心的上層細項(例如住宅含家庭能源):在「只看核心」模式下,它的貢獻是底下核心細項的加總,漲幅與異常標記不顯示。
11.7 驗證
這些比對由 detail/validate.py 在每次資料更新時重新執行。
12. 限制與參考資料
- 相對重要性本質上是未季調概念,月增率用它乘季調漲幅,會留下約 0.001pp 的 residual。
- 2007 年前指數只有一位小數,標準年增率的 residual 約 0.04pp。
- 新一年的 12 月表公布前,當年權重使用反推值,頁面底部會註明。
參考資料:
US CPI contributions: methodology
Where every number on the dashboard and the item detail page comes from: data, weights (relative importance), MoM and YoY contributions, the residual, item-level anomaly flags, and how the results were validated.
1. Goal and notation
The question: "headline CPI rose X%; how many percentage points came from each component?" A component's contribution depends on two things: how big it is in the basket (its weight) and how much its price moved.
| Symbol | Meaning |
| \(I_i(t)\) | CPI-U index of component \(i\) in month \(t\) (all items: \(I_{\text{all}}\)) |
| \(RI_i(t)\) | Relative importance: component \(i\)'s share of total expenditure in month \(t\) (%). Mutually exclusive components sum to 100 |
| \(c_i(t)\) | Contribution, in percentage points (pp). Components sum to ≈ the headline change |
| weight year \(y\) | The period that uses one set of expenditure weights: January to December of year \(y\) |
| anchor \(a_y\) | Start of weight year \(y\): December of \(y-1\) |
2. Data
2.1 Indexes
All from the BLS Public Data API, CPI-U, U.S. city average. MoM uses seasonally adjusted series (CUSR0000 + item code); YoY uses not seasonally adjusted series (CUUR0000 + item code), the same convention as the BLS news release and Bloomberg.
2.2 Weights
Every year BLS publishes "Relative importance of components in the Consumer Price Indexes: U.S. city average, December" (Table 1): the December relative importance of every item for the U.S. city average. The project parses 47 of these tables for 1987–2025, including the old-weights editions. Item codes changed over time (Food was SA11 in 1987), so rows are matched by name. Tables before 2010 have no Energy services row; it is derived as Energy − Energy commodities.
BLS posts each new December table in January, together with the weight update.
3. How the CPI aggregates
The CPI is a modified Laspeyres (Lowe) index: a fixed basket of quantities, repriced each month. Relative to an anchor month \(a\), the all-items index is the weighted mean of the price relatives of any mutually exclusive, exhaustive set of components, weighted by their expenditure shares in the anchor month:
$$\frac{I_{\text{all}}(t)}{I_{\text{all}}(a)} \;=\; \sum_i s_i(a)\,\frac{I_i(t)}{I_i(a)}, \qquad \sum_i s_i(a)=1 \tag{1}$$
with \(s_i(a)=RI_i(a)/100\). Equation (1) holds exactly (up to index rounding) within one weight year. It breaks across a weight update, which is the main source of the residual in section 8.
BLS weight updates (weight years → expenditure reference period):
Updated every two years from 2002 to 2022 and every year since 2023. Each December is the anchor of a new weight year, even when the expenditure data did not change.
4. Expenditure weights and relative importance
"Weight" means two different things in the CPI. Expenditure weights decide what goes into the basket and how much of it. Relative importance is each item's share of the cost of that same basket in a given month, priced at that month's prices. Both answer "how big is this item in the CPI?"; they differ in which month's prices the answer uses. Contributions need the second one.
4.1 Two terms
Expenditure weights. The 2026 CPI uses "2024 weights": what U.S. households spent on each item in 2024. Dividing those amounts by 2024 prices fixes the quantity of each item, and that fixed-quantity basket is used for the whole weight year. This is the Laspeyres (Lowe) index of section 3: the basket stays the same, only prices move.
Relative importance. Quantities are fixed but prices move every month. Reprice the same basket at this month's prices and each item's percentage of the total cost is its RI. An item whose price rises faster than average gains RI, even though the quantity bought has not changed at all.
4.2 From expenditure weights to relative importance
Let \(b\) be the expenditure reference period (say 2024), \(E_i(b)\) the amount spent on item \(i\) then, and \(P_i\) its price. The implied quantity is \(q_i = E_i(b)/P_i(b)\), and the cost of the same basket at month-\(t\) prices is
$$C_i(t) \;=\; q_i\,P_i(t) \;=\; E_i(b)\cdot\frac{P_i(t)}{P_i(b)} \;=\; E_i(b)\cdot\frac{I_i(t)}{I_i(b)}$$
\(C_i(t)\) is what BLS calls a cost weight, in dollars. Relative importance is the same thing as a percentage:
$$RI_i(t) \;=\; \frac{C_i(t)}{\sum_j C_j(t)}\times 100$$
Cost weights and RI are therefore one quantity in two units, which is why the project does not use cost weights separately (section 2.2). In practice BLS does this at the item × area level and aggregates to the U.S. city average. CPI-U and CPI-W cover different populations and have different RIs (December 2025 food: 13.698 in CPI-U, 14.889 in CPI-W); this project uses CPI-U throughout.
Compare two months \(a\) and \(t\). With quantities fixed, the change in total cost is the change in the all-items index, \(\sum_j C_j(t)/\sum_j C_j(a) = I_{\text{all}}(t)/I_{\text{all}}(a)\). Substituting gives the price-update formula (2) of section 4.5:
$$\frac{RI_i(t)}{RI_i(a)} \;=\; \frac{C_i(t)/C_i(a)}{\sum_j C_j(t)/\sum_j C_j(a)} \;=\; \frac{I_i(t)/I_i(a)}{I_{\text{all}}(t)/I_{\text{all}}(a)}$$
So the RI of one month plus the indexes afterwards give the RI of any later month, without knowing the dollar amounts at all.
4.3 A worked example
Simplified, made-up numbers with three items, for illustration only.
In 2024 households spend $1,400 on food, $400 on gasoline and $8,200 on everything else: $10,000 in total. By December 2025 food is up 3%, gasoline 20% and everything else 4%. The same basket in December 2025:
Gasoline's share rises from 4.00% to 4.59%, yet households buy the same quantity of it; only its relative price changed.
One more month: in January 2026 gasoline rises another 10% and nothing else moves.
Headline CPI rises \(10{,}498/10{,}450-1 = 0.459\%\). Contributions computed with the base-month (December) RI add up to exactly 0.459. The 2024 expenditure weights give 0.400: they understate the item that rose most and do not add back to the headline. January's RI has moved again (gasoline 5.03%); it is the weight for February's contributions.
4.4 Reading a BLS table title
BLS titles its annual table like this: Table 1 (2024 Weights). Relative importance of components … December 2025. Taken apart:
- 2024 Weights: the expenditure reference period; the basket comes from 2024 spending.
- December 2025: the shares of that basket priced at December 2025 prices.
- The table is the anchor of weight year 2026: every 2026 RI is derived from it with (2).
Timeline: 2024 spending is surveyed → price-updated to December 2025 → used from January 2026. The expenditure data lag the year of use by two years because the survey takes time to process. The weight year → expenditure period mapping is in the table in section 3.
4.5 Within the year
From the derivation in section 4.2, from anchor \(a\) to month \(t\):
$$RI_i(t) \;=\; RI_i(a)\cdot\frac{I_i(t)/I_i(a)}{I_{\text{all}}(t)/I_{\text{all}}(a)} \tag{2}$$
This is BLS's standard price-update formula. Summing (2) over components and using (1) gives 100 again. The project uses it to derive every month's RI from the official December anchor, and the result matches the RI in BLS's monthly news release exactly (section 10.4).
4.6 December has two sets of weights
- Old basis \(RI_i^{\text{old}}(\text{Dec } y)\): weight year \(y\)'s basket, price-updated to December by (2).
- New basis \(RI_i^{\text{new}}(\text{Dec } y)\): the shares of the basket built from the new expenditure weights, at December prices: the anchor of weight year \(y+1\). This is the table BLS publishes every December.
The two differ only because the basket (the expenditure weights) changed; the prices are the same month's. Contributions always use base-period weights. When December is the base (January MoM, the following December's YoY), the price change happens inside weight year \(y+1\), so the new basis is the right one. The project sets every December's \(RI\) to the new basis; without that, December contributions do not add up.
4.7 Common misconceptions
- "The weights change once a year." Only the expenditure weights (the basket) do; relative importance changes every month.
- "An item's RI went up, so people are buying more of it." Within a weight year quantities are fixed; a higher RI only means its price rose faster than average. Changes in what people buy show up only at a weight update.
- "Contributions can use the expenditure weights." No. They need the base month's RI, or, as in the example in 4.3, items with large price increases are understated and the pieces do not add up.
- "RIs cannot be added." For the same month, the same index population (e.g. all CPI-U) and mutually exclusive items they can: food + energy + core goods + core services = 100, and the project builds "core services ex shelter" by adding and subtracting. What cannot be added: RIs from different months, CPI-U mixed with CPI-W, RIs mixed with expenditure weights, or overlapping items (e.g. Food and Food at home).
- "Cost weights carry information beyond RI." They are RI expressed in dollars (the all-items cost weight × RI); the information is the same.
5. Where the anchor weights come from
5.1 Official tables (default)
The anchor of weight year \(y\) is BLS's December \(y-1\) table. For each parent → children group, a child's share inside its parent is:
$$s_{i\mid P}(a_y) \;=\; \frac{\widetilde{RI}_i}{\sum_{j\in P}\widetilde{RI}_j}$$
where \(\widetilde{RI}\) is the published value, rounded to three decimals. Dividing by the sum of the children rather than by the parent absorbs the ±0.001pp rounding gap, so the children add up to the parent exactly.
5.2 Recovered from the indexes (fallback)
Used only for weight years with no official table, for example before BLS posts the latest December table. Equation (1) is linear in the unknown \(s_i\). With \(x_{i,t}=I_i(t)/I_i(a)\) and \(b_t=I_P(t)/I_P(a)\), a year gives up to 12 equations, solved as constrained least squares:
$$\min_{s}\ \sum_{t}\Big(\sum_i s_i\,x_{i,t}-b_t\Big)^2 \quad \text{s.t.}\ \sum_i s_i = 1$$
Substituting \(s_n = 1-\sum_{i\lt n}s_i\) turns it into ordinary least squares:
$$\sum_{i\lt n} s_i\,(x_{i,t}-x_{n,t}) \;=\; b_t - x_{n,t}$$
When there are fewer months than unknowns (e.g. only January is out), the previous year's anchor shares are carried forward.
Precision. Before January 2007 BLS published indexes to one decimal. The fit error of (1) rises from about \(3\times10^{-6}\) to about \(5\times10^{-4}\), and because the components' price relatives are highly collinear within a year, food and services cannot be told apart. Recovered weights are within about ±0.05pp of the official ones after 2007 but can be 1–4pp off before. Recovery is therefore only a fallback, and also a check that the official tables were parsed correctly (section 10).
6. Hierarchy and composite components
Weights are built top-down from these mutually exclusive, exhaustive groups: child weight = parent weight × the child's share inside the parent.
Weights and contributions are linear, so components can be added and subtracted. "Core services ex shelter" is built this way:
$$\text{Core services ex shelter} \;=\; \underbrace{(\text{Services}-\text{Energy services})}_{\text{core services}}-\text{Rent of shelter} \;=\; \text{Services less rent of shelter}-\text{Energy services}$$
7. Contribution formulas
\(RI\) is in %, contributions in percentage points.
7.1 Month over month (seasonally adjusted)
$$c_i^{\text{MoM}}(t) \;=\; RI_i(t-1)\cdot\left(\frac{I^{SA}_i(t)}{I^{SA}_i(t-1)}-1\right)$$
7.2 Year over year (not seasonally adjusted, standard)
$$c_i^{\text{YoY}}(t) \;=\; RI_i(t-12)\cdot\left(\frac{I_i(t)}{I_i(t-12)}-1\right)$$
This is Bloomberg WMA's method and the dashboard default.
7.3 Composite components
For a composite \(C=\sum_k \sigma_k\,k\) with \(\sigma_k=\pm1\), both weight and contribution are signed sums: \(RI_C=\sum_k\sigma_k RI_k\), \(c_C=\sum_k\sigma_k c_k\).
8. The residual and the exact sum
8.1 What the residual is
$$r(t) \;=\; \underbrace{\left(\frac{I_{\text{all}}(t)}{I_{\text{all}}(t-h)}-1\right)\times 100}_{\text{published headline change}} \;-\; \sum_i c_i(t)$$
It is the gap between the sum of the contributions and the published headline. For March 2026: 3.256 − (0.366 + 0.791 + 0.229 + 1.847) = 0.023. It has three sources:
- YoY crosses a weight update (the main one). Equation (1) only holds within a weight year. When the base \(t-12\) and \(t\) fall in different weight years, base weights times component changes do not add back to the headline. The counter-example confirms this: December YoY is based on the previous December's new basis, so the whole year sits in one weight year and the residual is 0 (2025-12 shows 0.000).
- Rounding. Indexes are published to three decimals (one before 2007) and official weights to three decimals.
- Seasonal adjustment (MoM only). Seasonal factors are estimated series by series, so seasonally adjusted headline is not exactly the weighted sum of seasonally adjusted components. The gap is about 0.001pp.
8.2 Exact sum (chained decomposition)
With "Exact sum" on, YoY is built month by month. First each step between consecutive published months \(p\to m\) (NSA) is decomposed and its tiny residual is shared out in proportion to the weights:
$$c_i^{(1)}(m) = RI_i(p)\left(\frac{I_i(m)}{I_i(p)}-1\right) + r^{(1)}(m)\cdot\frac{|RI_i(p)|}{\sum_j |RI_j(p)|}$$
Let \(g_k\) be the headline change of step \(k\), in time order \(k=1,\dots,K\) from the month after the base to \(t\). The telescoping identity
$$\prod_{k=1}^{K}(1+g_k)-1 \;=\; \sum_{k=1}^{K} g_k\prod_{j\lt k}(1+g_j)$$
with each \(g_k=\sum_i c_i^{(1)}(k)\) exactly, gives
$$c_i^{\text{YoY, exact}}(t) \;=\; \sum_{k=1}^{K} c_i^{(1)}(k)\prod_{j\lt k}(1+g_j)$$
The components add up exactly to the published YoY, and because every step lies inside one weight year the January reset does no harm. Intuitively, an early month's contribution compounds with the headline growth that follows it. For MoM, exact mode shares the seasonal-adjustment residual out in proportion to the weights.
9. Missing months
BLS did not publish the October 2025 CPI because of the federal government shutdown. Every calculation chains over published months only:
- November 2025 MoM is a two-month change, September to November (orange underline on the chart).
- YoY is still a true 12-month change; the chained version just has one link fewer.
- October 2026 YoY has no base index; it will follow whatever BLS does at that point.
10. Validation
10.1 Against Bloomberg WMA (March 2026 YoY, pp)
July 2026 MoM (0.074 / 0.215 / 0.011 / −0.110 / 0.037 / 0.137) matches item by item.
10.2 Recovered vs official weights
Gap in the December weights of the four main components: mostly within ±0.05pp after 2007 (0.35pp in 2011), 1–4pp before. Year-by-year detail: data/ri_official_vs_estimated.csv.
10.3 The price-update formula (2)
Rolling an official December table forward one year with (2) and comparing it with BLS's "old weights" table for the same December: within 0.001pp since 2021, within 0.02pp before.
10.4 Against the monthly weights in the news release
Table 1 of each CPI news release lists the previous month's relative importance. For the August 2026 release (July weights), the July weights this project rolls forward from the December anchor with (2) are identical to the published ones:
10.5 Against the San Francisco Fed
The Federal Reserve Bank of San Francisco publishes CPI Inflation Contributions from Goods and Services every month. It splits YoY (not seasonally adjusted) and MoM (seasonally adjusted) CPI inflation into food, energy, core goods, core services excluding shelter, and shelter, with an Excel download. Building the same five groups from this project's seven components and comparing 331 months, January 1999 to August 2026 (pp; SF Fed rounds to two decimals):
Most of the gap comes from the definition of shelter: SF Fed's Shelter is BLS Shelter (SAH1), while this project uses Rent of shelter (SAS2RS). The difference is exactly one item, tenants' and household insurance (December 2025 weights: 35.625 − 35.333 = 0.292), which this project counts in "core services ex shelter". The rest is rounding, and the fact that the seven components are built from different aggregates that each keep their own residual. SF Fed also publishes contributions of 67 subcategories to monthly core CPI, a finer split this project does not have yet.
11. The item detail page
The item detail page follows the BLS expenditure hierarchy down to level 5, so you can see which items pushed inflation up or down in a given month, with unusual moves flagged. The method is the same as the main page's, applied item by item.
11.1 Scope and data
- Items: the expenditure-category hierarchy of the newest December table, level 1 (the eight major groups) to level 5: 239 items, 166 of them at the lowest level. The lowest-level items are mutually exclusive and their weights add up to about 100.
- The lowest level is not always level 5: some items are not split further below a shallower level and are lowest-level items themselves.
- Hierarchy repair: a few rows in BLS's Excel table are indented wrongly (e.g. "Alcoholic beverages" placed under "Food"); the code detects and fixes them by requiring every parent's weight to equal the sum of its children's.
- Indexes: BLS bulk files (download.bls.gov), CPI-U U.S. city average, seasonally adjusted and not.
- Months: the last 10 years are selectable; item price-change history starts in 2006 for the anomaly comparison.
11.2 Weights and contributions
As in sections 4 and 7, item by item:
- December anchors: the item's relative importance in each December table (new basis), matched by name; items BLS renamed are matched to older tables by their earlier names (Airline fares is "Airline fare" in the 2014–2016 tables).
- Within the year: price-updated with (2).
- MoM contribution: \(RI_i(p)\cdot\big(I_i(t)/I_i(p)-1\big)\), \(p\) the previous published month; seasonally adjusted index where BLS publishes one, otherwise not seasonally adjusted (badged "NSA"). About 34 lowest-level items, some 11% of the weight, have no seasonally adjusted index (e.g. wireless telephone services, health insurance); BLS does not adjust series without identifiable seasonality.
- YoY contribution: \(RI_i(t-12)\cdot\big(I_i(t)/I_i(t-12)-1\big)\), not seasonally adjusted.
11.3 Items without a published index
- Unsampled items and the odd item with no U.S. index (23 items, about 2% of the weight; "unsampled owners' equivalent rent of secondary residences" alone is about 1.2%): BLS publishes their weight but no index. They are estimated from the change of the nearest level above that has one and badged "est"; BLS imputes such items from the level above too.
- Items missing in some months (BLS withholds them when the sample is too small): for the weights only, they move with the level above; their own change and contribution for that month show "no data" and are not estimated.
11.4 Remainder
$$\text{remainder}(t) \;=\; \text{headline change}(t) \;-\; \sum_{i\in\text{lowest level}} c_i(t)$$
Its sources are those of the residual in section 8.1 (YoY spanning the weight update, rounding, seasonal adjustment) plus items not published that month. The finer the split, the larger the weight-update effect on YoY. September 2016 to August 2026: MoM mean 0.019pp, max 0.077pp; YoY mean 0.079pp, max 0.28pp.
11.5 Unusual moves
The flag compares the item's own change, not its contribution (items with large weights always have large contributions, so a contribution test would keep flagging the same items). For the selected month \(t\), take the item's changes of the same kind (MoM with MoM, YoY with YoY) over the 120 months before \(t\), \(g_{t-120},\dots,g_{t-1}\), with at least 36 observations:
$$z_t \;=\; \frac{g_t-\bar g}{s_g}, \qquad \text{percentile}_t \;=\; 100\times\frac{\#\{g_j < g_t\}}{\#\{g_j\}}$$
where \(\bar g\) and \(s_g\) are the mean and standard deviation over those 120 months. \(|z_t|\ge 2\) is flagged ▲ (unusually high) or ▼ (unusually low). Rankings and the default table order are still by contribution. The grey band in an item's history chart is \(\bar g \pm 2 s_g\) (right axis).
11.6 Depth and "core only"
- Depth \(d\): the ranking uses the items at level \(d\) plus shallower items that have no children, so at any depth the items are mutually exclusive and cover everything. "Lowest" is the 166 lowest-level items.
- Core: items not under "Food", "Household energy" or "Motor fuel", matching BLS's "All items less food and energy".
- Parents that mix core and non-core items (e.g. Housing, which contains household energy): in core-only mode their contribution is the sum of their core descendants; change and flags are not shown.
11.7 Validation
detail/validate.py reruns these comparisons with every data update.
12. Limitations and references
- Relative importance is a not-seasonally-adjusted concept; applying it to seasonally adjusted changes leaves a residual of about 0.001pp in MoM.
- Before 2007 indexes have one decimal, so the standard YoY residual is about 0.04pp.
- Until BLS posts the latest December table, that year's weights are recovered; the dashboard footnote says so.
References: