---
title: "Decomposing price indexes"
format: 
  html:
    html-math-method: mathjax
    options:
      number_sections: true
vignette: >
  %\VignetteIndexEntry{Decomposing price indexes}
  %\VignetteEngine{litedown::vignette}
  %\VignetteEncoding{UTF-8}
---

*This vignette presents an extended version of Martin (2021), and shows how to use the tools in this package to make these decompositions.*

It is often useful to be able to decompose a price index into an additive or multiplicative form to evaluate how each input to the index affects its value. Following Balk (2008), a price index is said to admit an additive decomposition if there exist weights that allow it to be represented as an arithmetic mean of price relatives, and is said to admit a multiplicative decomposition if there are weights that allow it to be represented as a geometric mean. Switching prices for quantities gives the analogous statements for a quantity index, and nothing is lost by focusing on price indexes.

There are several well-known decompositions for the most common types of bilateral price indexes. Balk (2008, eq. 4.13) gives an additive decomposition for any index based on the geometric mean by transmuting the weights in the geometric mean with the logarithmic mean. This is the same decomposition derived by Reinsdorf et al. (2002, eq. 20) for the Törnqvist index. A similar approach yields a multiplicative decomposition for any index based on the arithmetic mean, again using the logarithmic mean (Balk, 2008, eq. 4.8). Combining these results gives additive and multiplicative decompositions for the Fisher index (Reinsdorf et al., 2002, sec. 6). The van IJzeren additive decomposition for the Fisher index (Balk, 2008, eq. 4.18) is an alternative that does not explicitly use the logarithmic mean. Each of these decompositions results in weights that are positive and sum to one, as required to represent an index as an arithmetic or geometric mean.[^1]

[^1]: There are decompositions with "weights" that do not sum to one, such as those for the Fisher index by Reinsdorf et al. (2002, sec. 2) and Hallerbach (2005), and for other superlative indexes by Diewert (2002). Balk (2008, eq. 4.28) gives the original multiplicative decomposition of the Fisher index, due to Vartia, for which the weights also do not sum to one. Webster and Tarnow-Mordi (2019) consider several decompositions for multilateral indexes, although again the "weights" do not sum to one.

I show how the additive and multiplicative decompositions for geometric, arithmetic, and Fisher indexes can be consolidated and made more general by switching out the logarithmic mean for the more general extended mean. The main result is a function that transmutes the weights in a generalized mean of a given order so that it can be represented as a generalized mean of any other order. This covers additive and multiplicative decompositions for indexes that do not belong to the arithmetic or geometric families, like harmonic indexes or the Lloyd-Moulton index, and allows both additive and multiplicative decompositions to be covered by a single equation, rather than treating them as different cases. Expressing a generalized-mean index as a generalized mean of any other order also allows for the decomposition of indexes that are nested generalized means, like the family of superlative quadratic mean indexes that includes the Fisher index or the AG mean index by Lent and Dorfman (2009). I demonstrate some useful properties of this general decomposition and show how it can be used to decompose indexes based on other types on means, including those that aggregate indexes according to a hierarchical structure, and decompose deflating a change in aggregate values with a price index. See Martin (2026) for an application of these methods to multilateral indexes. Throughout I show how the tools in the **piar** package can be used to decompose a price index.

## Decomposing generalized-mean indexes {#sec-decompose}

A natural extension to the decompositions of indexes based on the arithmetic and geometric means is to derive weights that transform an index based on a generalized mean of order $\rho$ into one based on a generalized mean of order $\varsigma$. To fix notation, let $\mathbf{r} = (r_{1}, r_{2}, \ldots, r_{n}) \in \mathbb{R}^{n}_{++}$ be a vector of price relatives for $n\geq2$ products and let $\mathbf{w} = (w_{1}, w_{2}, \ldots, w_{n}) \in \Delta^{n - 1}$ be the corresponding weights, where $\Delta^{n - 1} = \{\mathbf{w} \in \mathbb{R}_{+}^{n} | \sum_{i = 1}^{n} w_{i} = 1\}$ is the unit simplex. The goal is to find a vector-valued function
$$\mathbf{v}(\mathbf{r}, \mathbf{w}; \rho, \varsigma) = (v_{1}(\mathbf{r}, \mathbf{w}; \rho, \varsigma), v_{2}(\mathbf{r}, \mathbf{w}; \rho, \varsigma),\ldots, v_{n}(\mathbf{r}, \mathbf{w}; \rho, \varsigma))$$
mapping into $\Delta^{n - 1}$ such that
$$\mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w}) \equiv \mathfrak{M}_{\varsigma}(\mathbf{r}, \mathbf{v}(\mathbf{r}, \mathbf{w}; \rho, \varsigma)),$$
where $\mathfrak{M}_{\rho}$ is the generalized mean
$$\mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w}) = 
\begin{cases}
\left(\sum_{i = 1}^{n} w_{i} r_i^{\rho}\right)^{1 / \rho} & \text{if } \rho \neq 0 \\
\prod_{i = 1}^{n} r_{i}^{w_{i}} & \text{if } \rho = 0.
\end{cases}$$

Setting $\varsigma = 1$ then yields an additive decomposition for any index based on a generalized mean of order $\rho$, such that
$$\mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w}) = \sum_{i=1}^{n} r_{i} v_i(\mathbf{r}, \mathbf{w}; \rho, 1),$$
and setting $\varsigma = 0$ yields a multiplicative decomposition, such that
$$\mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w}) = \prod_{i=1}^{n} r_{i}^{ v_i(\mathbf{r}, \mathbf{w}; \rho, 0)}.$$
Note that any index that admits an additive decomposition can be used to derive percent-change contributions for each price relative, $v_i(\mathbf{r}, \mathbf{w}; \rho, 1) (r_i - 1)$, that sum up to $\mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w}) - 1$, although the converse is not true and it is possible to decompose an index into percent-change contributions that do not allow it to be represented as an arithmetic mean. Note also that other types of decompositions can be had by setting $\varsigma$ to a value other than 0 or 1; for example, setting $\varsigma = -1$ gives the harmonic decomposition (Färe and Karagiannis, 2025),
$$\mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w}) = 1 / \left(\sum_{i=1}^{n} v_i(\mathbf{r}, \mathbf{w}; \rho, -1) / r_{i}\right),$$
that will be useful in @sec:harmonic.

Balk (2008) and Reinsdorf et al. (2002) show how to derive $\mathbf{v}(\mathbf{r}, \mathbf{w}; \rho, \varsigma)$ when $\rho = 1$ and $\varsigma = 0$ (multiplicative decomposition of an arithmetic index)
$$v_{i}(\mathbf{r}, \mathbf{w}; 1, 0) = \frac{w_{i} \mathfrak{L}(r_{i}, \mathfrak{M}_{1}(\mathbf{r}, \mathbf{w}))}{\sum_{j=1}^{n} w_{j} \mathfrak{L}(r_{j}, \mathfrak{M}_{1}(\mathbf{r}, \mathbf{w}))}$$
and $\rho = 0$ and $\varsigma = 1$ (additive decomposition of a geometric index)
$$v_{i}(\mathbf{r}, \mathbf{w}; 0, 1) = \frac{w_{i} / \mathfrak{L}(r_{i}, \mathfrak{M}_{0}(\mathbf{r}, \mathbf{w}))}{\sum_{j=1}^{n} w_{j} / \mathfrak{L}(r_{j}, \mathfrak{M}_{0}(\mathbf{r}, \mathbf{w}))},$$
using the logarithmic mean
$$\mathfrak{L}(a, b) =
\begin{cases}
\frac{a - b}{\log(a / b)} & a \neq b\\
a & a = b.
\end{cases}$$

Generalizing these results follows from replacing the logarithmic mean with the more general extended mean (Bullen, 2003, p. 393), defined for any $a,b > 0$ as 
$$\mathfrak{E}_{\rho\varsigma}(a, b) =
\begin{cases}
\left(\frac{\varsigma(a^\rho - b^\rho)}{\rho(a^\varsigma - b^\varsigma)}\right)^{1 / (\rho - \varsigma)} & \rho \neq \varsigma, \rho \neq 0, \varsigma \neq 0, a \neq b \\
\left(\frac{a^\rho - b^\rho}{\rho\log(a / b)}\right)^{1 / \rho} & \rho \neq 0, \varsigma = 0, a \neq b \\
\left(\frac{a^\varsigma - b^\varsigma}{\varsigma\log(a / b)}\right)^{1 / \varsigma} & \rho = 0, \varsigma \neq 0, a \neq b \\
\frac{1}{\exp(1 / \rho)} \left(\frac{a^{a^\rho}}{b^{b^\rho}}\right)^{1 / (a^\rho - b^\rho)} & \rho = \varsigma  \neq 0, a \neq b \\
\sqrt{ab} & \rho = \varsigma = 0, a \neq b \\
a & a = b.
\end{cases}$$
The extended mean reduces to the logarithmic mean when either $\rho = 0$ and $\varsigma = 1$, or $\rho = 1$ and $\varsigma = 0$. But using the extended mean in place of the logarithmic mean allows for decompositions of indexes based on other types of means, like harmonic indexes ($\rho = -1$) and the Lloyd-Moulton index ($\rho = 1 - \sigma$, where $\sigma$ is an elasticity of substitution).

The key to transforming the weights in a generalized mean of order $\rho$ into the weights for a generalized mean of order $\varsigma$ comes from noting that the extended mean is always strictly positive and satisfies the identity
$$\begin{align}
\sum_{i=1}^{n} w_{i} \mathfrak{E}_{\rho\varsigma}(r_i, \mathfrak{M}_{\rho} (\mathbf{r}, \mathbf{w}))^{\rho - \varsigma} \varepsilon_{i}(\mathbf{r}, \mathbf{w}; \rho, \varsigma) \equiv 0,\label{eq:identity}
\end{align}$$
where
$$\varepsilon_{i}(\mathbf{r}, \mathbf{w}; \rho, \varsigma) = 
\begin{cases}
r_i^\varsigma - \mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w})^\varsigma & \text{if } \varsigma \neq 0, \\
\log(r_i) - \log(\mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w})) & \text{if } \varsigma = 0.
\end{cases}$$
@eqn:identity uses the extended mean to keep the weighted deviation from the mean constant for each price relative (up to a common factor of proportionality) when changing the order of the mean from $\rho$ to $\varsigma$, without changing the value of the mean. Rearranging then gives that
$$\begin{align}
v_{i}(\mathbf{r}, \mathbf{w}; \rho, \varsigma) =  w_{i} \mathfrak{E}_{\rho\varsigma}(r_i, \mathfrak{M}_{\rho} (\mathbf{r}, \mathbf{w}))^{\rho - \varsigma} \Bigg/ \sum_{j=1}^{n} w_{j} \mathfrak{E}_{\rho\varsigma}(r_j, \mathfrak{M}_{\rho} (\mathbf{r}, \mathbf{w}))^{\rho - \varsigma}\label{eq:res1}
\end{align}$$
is a suitable function to find weights that turn an index based on a generalized mean of order $\rho$ into one based on a generalized mean of order $\varsigma$.

The function given by @eqn:res1 takes on all existing decompositions that I know of as special cases. Setting $\rho = 0$ and $\varsigma = 1$, or $\rho = 1$ and $\varsigma = 0$, gives the special cases by Balk (2008) and Reinsdorf et al. (2002) for decomposing indexes based on arithmetic and geometric means (because the extended mean reduces to the logarithmic mean). Similarly, because $\mathfrak{E}_{\rho\varsigma}(r_i, \mathfrak{M}_{\rho} (\mathbf{r}, \mathbf{w}))^{\rho - \varsigma} \equiv \left(\mathfrak{M}_{\rho} (\mathbf{r}, \mathbf{w}) r_{i}\right)^\rho$ when $\rho = -1$ and $\varsigma = 1$, or $\rho = 1$ and $\varsigma = -1$, setting $\rho = -1$ and $\varsigma = 1$ reduces @eqn:res1 to 
$$v_{i}(\mathbf{r}, \mathbf{w}; -1, 1) = \frac{w_{i} / r_{i}}{\sum_{i=1}^{n}w_{i} / r_{i}} ;$$
if $\mathbf{w}$ is a vector of current-period expenditure/revenue shares then these are the hybrid weights that allow a Paasche index to be calculated as an arithmetic mean of price relatives. Setting $\rho = 1$ and $\varsigma = -1$ reduces @eqn:res1 to
$$v_{i}(\mathbf{r}, \mathbf{w}; 1, -1) = \frac{w_{i} r_{i}}{\sum_{i=1}^{n}w_{i} r_{i}}.$$
If $\mathbf{w}$ is a vector of base-period expenditure/revenue shares then these are the hybrid weights that allow a Laspeyres index to be calculated as a harmonic mean of price relatives. As should be expected, the weights are unchanged if $\rho = \varsigma$ or each element of $\mathbf{r}$ takes on the same value.

### Transitivity, monotonicity, and uniqueness

The extended mean has two properties that make it useful for decomposing price indexes. First, the order of the extended mean has a transitivity property under multiplication: $\mathfrak{E}_{\rho\varsigma}(a, b)^{\rho - \varsigma} = \mathfrak{E}_{\rho\tau}(a, b)^{\rho - \tau}\mathfrak{E}_{\tau\varsigma}(a, b)^{\tau - \varsigma}$. This means the function in @eqn:res1 is transitivity, such that transmuting the weights to turn a generalized mean of order $\rho$ into a generalized mean of order $\tau$, and then transmuting these weights again to turn a generalized mean of order $\tau$ into a generalized mean of order $\varsigma$, is the same as finding weights to make a generalized mean of order $\rho$ into one of $\varsigma$. That is,
$$\mathbf{v}(\mathbf{r}, \mathbf{v}(\mathbf{r}, \mathbf{w}; \rho, \tau); \tau, \varsigma) \equiv \mathbf{v}(\mathbf{r}, \mathbf{w}; \rho, \varsigma).$$
As will be seen later, not all decompositions have this property.

Second, the extended mean is a strictly increasing function in both arguments (Bullen, 2003, p. 395). This means that the function in @eqn:res1 has a monotonicity property whereby the transmuted weights increase (decrease) for large (small) price relatives if and only if $\rho > \varsigma$. That is, assuming $\mathbf{r}$ is ordered from smallest to largest (and does not contain all the same value), if $\rho > \varsigma$ then there is a pair of integer $k,l$, with $k\leq l$, such that $v_{i}(\mathbf{r}, \mathbf{w}; \rho, \varsigma) \geq w_{i}$ for $i\geq l$ and $v_{i}(\mathbf{r}, \mathbf{w}; \rho, \varsigma) \leq w_{i}$ for $i\leq k$, with these equalities reversed if $\rho < \varsigma$.[^2] Again, not all decompositions satisfy this property.

[^2]: These are weak inequalities to account for the case that some weights are 0. If the vector if weights is strictly positive then the inequalities are strict.

The decomposition given by @eqn:res1 is unique when $n = 2$ and $r_{1} \neq r_{2}$, and is the only such function that always returns $\mathbf{w}$ when $r_{1} = r_{2}$. But @eqn:res1 is necessarily not unique when $n\geq3$, and there are infinitely many ways to decompose an index based on the generalized mean.[^3] Nonetheless, the limited case of uniqueness will be useful in @sec:superlative.

[^3]: Take, for example, (1/2, 1, 3/2) with weights (1/6, 1/3, 1/2). The weighted harmonic mean is 1, which can be computed as an arithmetic mean with weights (1/3, 1/3, 1/3) or (1/4, 1/2, 1/4). Hence there are multiple additive decompositions for the harmonic mean.

### Numerical example

Consider the following numerical example for decomposing a quadratic-mean index (von der Lippe, 2007, p. 61) (i.e., a producer price index with an elasticity of substitution of -1) made using the price and quantity data from Balk (2008, tab. 3.1--3.2). The `transmute_weights()` function parameterizes the decomposition in @eqn:res1 to make a function that decomposes any generalized-mean index.

```{r}
library(piar)

p2 <- c(1.2, 3, 1.3, 0.7, 1.4, 0.8)
p1 <- 1
q2 <- c(0.8, 0.9, 1.9, 1.3, 4.7, 0.6)
q1 <- c(1, 1, 2, 1, 4.5, 0.5)

rel <- p2 / p1

s1 <- scale_weights(p1 * q1)
s2 <- scale_weights(p2 * q2)

v <- transmute_weights(rel, s1, order = 2)

all.equal(gmean(rel, s1, order = 2), gmean(rel, v))
```

Because the quadratic mean is larger than the arithmetic mean, the weight from the smaller price relatives is transferred to the largest price relative.

```{r}
(v - s1)[order(rel)]
```

It is also readily seen that turning the arithmetic decomposition into a geometric one is the same as directly constructing the multiplicative decomposition.

```{r}
all.equal(
  transmute_weights(rel, v, order = 1, to = 0),
  transmute_weights(rel, s1, order = 2, to = 0)
)
```

## Extensions

### Decomposing superlative indexes {#sec:superlative}

The additive and multiplicative decompositions for the Fisher index by Reinsdorf et al. (2002, sec. 6) can be generalized in the same way as the decompositions for the arithmetic and geometric indexes by noting that the Fisher index is simply a nested generalized mean of indexes based on the generalized mean. For a pair of generalized means $\mathfrak{N}_{\rho_{1}\rho_{2}}(\mathbf{r}, \mathbf{w}_{1}, \mathbf{w}_{2})=\left(\mathfrak{M}_{\rho_1}(\mathbf{r}, \mathbf{w}_1), \mathfrak{M}_{\rho_2}(\mathbf{r}, \mathbf{w}_2)\right)$ mapping into $\mathbb{R}_2^{++}$ with weights $\mathbf{\omega}=(\omega_1, \omega_2) \in \Delta^1$, an index based on nested generalized means is written as
$$\begin{align}
\mathfrak{M}_{\rho}\left(\mathfrak{N}_{\rho_{1}\rho_{2}}(\mathbf{r}, \mathbf{w}_{1}, \mathbf{w}_{2}), \mathbf{\omega}\right). \label{eq:superlative}
\end{align}$$

The general family of superlative quadratic mean indexes of order $\tau$ comes from setting $\rho = 0$, $\rho_1 = \tau / 2$, and $\rho_2 = -\tau / 2$ when $\omega_1 = \omega_2 = 1 / 2$, $\mathbf{w}_1$ are base-period expenditure/revenue shares, and $\mathbf{w}_2$ are current-period expenditure/revenue shares. In particular, setting $\tau = 2$ gives the Fisher index and setting $\tau = 1$ gives the implicit Walsh index. But @eqn:superlative covers other types of indexes as well; for example, setting each element of $\mathbf{w}_1$ and $\mathbf{w}_2$ to $1 / n$ when $\tau = 2$ gives the Carruthers-Sellwood-Ward-Dalén index that serves as an estimator for the Fisher index, whereas $\tau = 1$ gives the Balk-Walsh index. Setting $\rho = -1$ gives the harmonic analogue of the Fisher index, which is not a superlative quadratic mean indexes of order $\tau$. Finally, setting $\rho = \rho_{1} = \rho_{2}$ and $\mathbf{w}_{1} = \mathbf{w}_{2}$ gives an index based on a generalized mean of order $\rho$, so that the decomposition of an index based on the generalized mean is a special case of the decomposition for @eqn:superlative.

An index of the form in @eqn:superlative can be decomposed into an index based on the generalized mean of order $\rho$ using the weights in @eqn:res1, as it can be written as the generalized mean
$$\mathfrak{M}_{\rho}(\mathbf{r}, \omega_1 \mathbf{v}(\mathbf{r}, \mathbf{w}_1; \rho_1, \rho) + \omega_2\mathbf{v}(\mathbf{r}, \mathbf{w}_2; \rho_2, \rho)).$$
The transformation in @eqn:res1 then applies as before, just replacing $\mathbf{w}$ with the more complicated weights $\omega_1 \mathbf{v}(\mathbf{r}, \mathbf{w}_1; \rho_1, \rho) + \omega_2\mathbf{v}(\mathbf{r}, \mathbf{w}_2, \rho_2, \rho)$, which can be written as
$$\begin{align}
\mathbf{v}(\mathbf{r}, \omega_1 \mathbf{v}(\mathbf{r}, \mathbf{w}_1; \rho_1, \rho) + \omega_2\mathbf{v}(\mathbf{r}, \mathbf{w}_2; \rho_2, \rho); \rho, \varsigma). \label{eq:res2}
\end{align}$$
The idea is to transmute the weights for both inner means to be of the same order as the outer mean ($\rho$) so that they can be added together, and then transmute these weights to represent the outer generalized mean as a mean of order $\varsigma$. Note that this means the decomposition satisfies the same transitivity property as @eqn:res1 with respect to $\rho$ and $\varsigma$.

Continuing with the previous example, the `transmute_weights2()` function parameterizes the decomposition in @eqn:res2 and can be used to decompose the Fisher index.

```{r}
v1 <- transmute_weights2(rel, list(s1, s2))

all.equal(nested_gmean(rel, list(s1, s2)), gmean(rel, v1))

all.equal(
  v1,
  transmute_weights(
    rel,
    transmute_weights2(rel, list(s1, s2), to = 2),
    order = 2
  )
)
```

An alternative approach to decompose @eqn:superlative is to generalize the (additive) van IJzeren decomposition for the Fisher index, which can be written as
$$\begin{align}
v_{1}(\mathfrak{N}_{\rho_{1}\rho_{2}}(\mathbf{r}, \mathbf{w}_{1}, \mathbf{w}_{2}), \mathbf{\omega}; \rho, \varsigma) \mathbf{v}(\mathbf{r}, \mathbf{w}_1; \rho_1, \varsigma) + v_{2}(\mathfrak{N}_{\rho_{1}\rho_{2}}(\mathbf{r}, \mathbf{w}_{1}, \mathbf{w}_{2}), \mathbf{\omega}; \rho, \varsigma) \mathbf{v}(\mathbf{r}, \mathbf{w}_2; \rho_2, \varsigma).\label{eq:res3}
\end{align}$$
Note that for a Fisher index, if $\varsigma=1$ then $\mathbf{v}(\mathbf{r}, \mathbf{w}_1; \rho_1, \varsigma)$ is a vector of base-period expenditure/revenue shares, $\mathbf{v}(\mathbf{r}, \mathbf{w}_2; \rho_2, \varsigma)$ is a vector of hybrid Paasche weights, and $\mathbf{v}(\mathfrak{N}_{\rho_{1}\rho_{2}}(\mathbf{r}, \mathbf{w}_{1}, \mathbf{w}_{2}), \mathbf{\omega}; \rho, \varsigma)$ are the unique weights that decompose the geometric mean of the Laspeyres and Paasche indexes, which equals the van IJzeren decomposition. The idea here is to transmute the weights for both the inner and outer generalized means so that they are means of order $\varsigma$, then take the product of these weights. @eqn:res2 and @eqn:res3 generally give different decompositions, as the latter is not transitive, but reduce to @eqn:res1 when $\rho = \rho_{1} = \rho_{2}$ and $\mathbf{w}_{1} = \mathbf{w}_{2}$.

These two approaches for decomposing @eqn:superlative can be generalized with a pivot value $\psi$ that acts as the link between the inner and outer generalized means. More generally, an index of the form in @eqn:superlative can be decomposed into a generalized mean of order $\rho$ with weights
$$\mathbf{v}(\mathbf{r},v_{1}(\mathfrak{N}_{\rho_{1}\rho_{2}}(\mathbf{r}, \mathbf{w}_{1}, \mathbf{w}_{2}), \mathbf{\omega}; \rho, \psi) \mathbf{v}(\mathbf{r}, \mathbf{w}_1; \rho_1, \psi) + v_{2}(\mathfrak{N}_{\rho_{1}\rho_{2}}(\mathbf{r}, \mathbf{w}_{1}, \mathbf{w}_{2}), \mathbf{\omega}; \rho, \psi) \mathbf{v}(\mathbf{r}, \mathbf{w}_2; \rho_2, \psi); \psi, \varsigma).$$
Setting $\psi=\rho$ gives @eqn:res2, whereas setting $\psi=\varsigma$ gives @eqn:res3.

```{r}
v2 <- transmute_weights2(rel, list(s1, s2), pivot = 1)

all.equal(nested_gmean(rel, list(s1, s2)), gmean(rel, v2))

all.equal(
  v2,
  transmute_weights(
    rel,
    transmute_weights2(rel, list(s1, s2), to = 2, pivot = 1),
    order = 2
  )
)
```

Overall the difference between the two approaches tends to be small.

```{r}
summary(v1 - v2)
```

### Decomposing aggregated indexes

The decomposition in @eqn:res3 can be extended to get a decomposition for an index constructed using the usual two-step procedure to make a price index. If price relatives are partitioned into $k$ groups, and an index is made from $k$ sub-indexes $\mathfrak{N}_{\rho_{1}\ldots\rho_{k}}(\mathbf{r}, \mathbf{w}_{1}, \ldots, \mathbf{w}_{k}) = \left(\mathfrak{M}_{\rho_1}(\mathbf{r}_{1}, \mathbf{w}_{1}), \ldots, \mathfrak{M}_{\rho_k}(\mathbf{r}_{k}, \mathbf{w}_{k})\right)$ with weights $\mathbf{\omega}=(\omega_{1},\ldots,\omega_{k})$ as a generalized mean of order $\rho$, then
$$v_{i}(\mathfrak{N}_{\rho_{1}\ldots\rho_{k}}(\mathbf{r}, \mathbf{w}_{1}, \ldots, \mathbf{w}_{k}), \mathbf{\omega}; \rho, \varsigma) \mathbf{v}(\mathbf{r}_{i}, \mathbf{w}_i; \rho_{i}, \varsigma)$$
decomposes how the components of the $i$-th sub-index contribute towards the total index. Concatenating each of these vectors of weights along with the vector of price relatives represents the nested mean over the partitioning of price relatives as a generalized mean of order $\varsigma$.

```{r}
group <- rep(c("a", "b"), each = 3)

s1_by_group <- split(s1, group)
rel_by_group <- split(rel, group)

index_a <- gmean(rel_by_group$a, s1_by_group$a, order = 2)
index_b <- gmean(rel_by_group$b, order = 0)

gmean(c(index_a, index_b), sapply(s1_by_group, sum), order = 2)

decomp_a <- transmute_weights(rel_by_group$a, s1_by_group$a, order = 2)
decomp_b <- transmute_weights(rel_by_group$b, order = 0)

v <- Map(
  `*`,
  transmute_weights(c(index_a, index_b), sapply(s1_by_group, sum), order = 2),
  list(decomp_a, decomp_b)
) |>
  unlist()

gmean(rel, v)
```

This approach to decomposing aggregate indexes also has the benefit that contributions for different groups can be made using different methods and combined in a way that decomposes the aggregated index. For example, the percent-change decomposition by Diewert (2002) can be used to decompose the Fisher index for one group, whereas percent-change contributions from the additive decomposition of a Jevons index can be used to decompose another group, and combined in a consistent way to get percent-change contributions for the aggregated index.

### Decomposing deflators {#sec:harmonic}

The decomposition in @eqn:res1 can be used to construct a decomposition for how a price index deflates a change in aggregate value over time to get a quantity index. Letting $V$ be the change in total value between two periods, the implicit quantity index for a price index based on the generalized mean of order $\rho$ is

$$
\frac{V}{\mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w})}.
$$

Using @eqn:res1 to find weights to represent $\mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w})$ as a harmonic mean means that
$$V/ \mathfrak{M}_{\rho}(\mathbf{r}, \mathbf{w}) \equiv \mathfrak{M}_{\varsigma}(V / \mathbf{r}, \mathbf{v}(\mathbf{r}, \mathbf{w}; \rho, -\varsigma)),$$
where $V / \mathbf{r} = \left(V / r_{1}, \ldots, V / r_{n}\right)$.

Setting $\varsigma=1$ then gives an additive decomposition for how each price relative acts to deflate the change in total value over time, while setting $\varsigma=0$ gives a multiplicative decomposition. The same holds true when deflating with an index based on nested means, using either @eqn:res2 or @eqn:res3.

```{r}
V <- sum(p2 * q2) / sum(p1 * q1)

v <- transmute_weights2(rel, list(s1, s2), to = -1)

all.equal(
  gmean(V / rel, v),
  nested_gmean(q2 / q1, list(s1, s2))
)

V / rel * v
```

### Decomposing contra-harmonic indexes

von der Lippe (2015) discusses using the contra-harmonic mean (or antiharmonic as he calls it), a special case of the Lehmer mean (Bullen, 2003, p. 245) (of order 2), to make price indexes.

```{r}
contraharmonic_mean <- function(x, weights, order) {
  gmean(x, weights * x)
}

# Arithmetic hybrid index
all.equal(
  gmean(p2 / p1, p2 * q1),
  contraharmonic_mean(p2 / p1, p1 * q1)
)

# Palgrave index
all.equal(
  gmean(p2 / p1, p2 * q2),
  contraharmonic_mean(p2 / p1, p1 * q2)
)
```

The Lehmer mean of order $\rho$ is simply the arithmetic mean of the with weights
$$\left(w_{1}r_{1}^{\rho - 1}, \ldots, w_{n}r_{n}^{\rho - 1}\right) / \sum_{i = 1}^{n} w_{i} r_{i}^{\rho - 1},$$
and so indexes based on these means can be decomposed with @eqn:res1 by using the these weights instead of $\mathbf{w}$.

## References {-}

Balk, B. M. (2008). _Price and Quantity Index Numbers_. Cambridge University Press. https://doi.org/10.1017/CBO9780511720758.

Bullen, P. S. (2003). _Handbook of Means and their Inequalities_. Springer Science+Business Media. https://doi.org/10.1007/978-94-017-0399-4.

Diewert, W. E. (2002). The quadratic approximation lemma and decompositions of superlative indexes. _Journal of Economic and Social Measurement_, 28(1-2): 63--88. https://doi.org/10.3233/JEM-2003-0200.

Färe, R., Karagiannis, G. (2025). An alternative derivation of the van IJzeren weights and some new results for the additive decomposition of Fisher indices. _Journal of Productivity Analysis_, 64(3): 363--377. https://doi.org/10.1007/s11123-025-00774-2.

Hallerbach, W. G. (2005). An alternative decomposition of the Fisher index. _Economics Letters_, 86(2): 147--152. https://doi.org/10.1016/j.econlet.2004.07.008.

Lent, J., Dorfman, A. H. (2009). Using a weighted average of base period price indexes to approximate a superlative index. _Journal of Official Statistics_, 25(1): 149--149.

Martin, S. (2021). A note on generalized decompositions for price indexes. _Prices Analytical Series_, Statistics Canada.

Martin, S. (2026). A note on the additive decomposition of GEKS indexes. _Journal of Official Statistics_, 0282423X261451318. https://doi.org/10.1177/0282423X261451318.

Reinsdorf, M. B., Diewert, W. E., Ehemann, C. (2002). Additive decompositions for Fisher, Törnqvist and geometric mean indexes. _Journal of Economic and Social Measurement_, 28(1--2): 51--61. https://doi.org/10.3233/JEM-2003-0194.

von der Lippe, P. (2007). _Index Theory and Price Statistics_. Peter Lang. https://doi.org/10.3726/978-3-653-01120-3.

von der Lippe, P. (2015). _Generalized Statistical Means and New Price Index Formulas, Notes on some unexplored index formulas, their interpretations and generalizations_. Munich Personal RePEc Archive paper no. 64952.

Webster, M. B., Tarnow-Mordi, R. C. (2019). _Decomposing multilateral price indexes into the contributions of individual commodities_. Journal of Official Statistics, 35(2): 461--486. https://doi.org/10.2478/jos-2019-0020.
