Calculate contribution of a series to 'all items' 12 month rate
Source:R/contribution.R
contribution.Rd
The contribution function implements the formula for calculating the contribution of a cpi component to its parent level, as set out in the ONS CPI Technical Manual.
The function must be applied to an unchained index. The unchain()
function
can be used to unchain a series. The formula is valid for data after 2018
when the CPI weights updated twice a year, and is set out below.
\(c = component\ c\)
\(a =\ 'all\ items'\ CPI\ index\)
\(W^c_{y} = weight\ of\ component\ c\ in\ year\ y\)
\(I^c_t = index\ for\ component\ c\ in\ month\ t\ based\ on\ January\ of\ current\ year =100\)
\(I^a_{Jan} = all\ items\ index\ for\ January\ based\ on\ previous\ month\ (December) = 100\)
\(I^a_{Dec} = all\ items\ index\ for\ December\ based\ on\ previous\ January = 100\)
$$ (\frac{W^c_{y-1}} {W^a_{y-1}}) \times (\frac{({I^c_{Dec}} - {I^c_{t-12}})}{I^a_{t-12}}) \times 100 \ \ +\ \ (\frac{W^c_y}{W^a_y}) \times (\frac{({I^c_{Jan}}-100)}{I^a_{t-12}}) \times I^a_{Dec} \ \ +\ \ (\frac{W^c_y}{W^a_y}) \times (\frac{(I^c_t - 100)}{I^a_{t-12}}) \times \frac{I^a_{Jan}}{100} \times I^a_{Dec} $$
You should apply contribution()
to a wide dataframe: one that has a field
containing the dates for the series, and columns containing the relevant
series indices and their weights.