--- title: "Contributions to percent change of chain-linked volume measures" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Contributions to percent change of chain-linked volume measures} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>") ``` ```{r setup} library(chainlink) ``` Chain-linked volume measures are not additive, so that the contribution of a component to the growth of the total cannot be read from the growth of the components. `chain_contrib()` computes exact contributions: they add up to the growth of the total (up to the inconsistencies of the data, see below). The formulas follow the chapter 8 of the IMF [*Quarterly National Accounts Manual*](https://doi.org/10.5089/9781475589870.069) (paragraphs 8.86-8.90). # Principle Let $x_{i,t}$ be the chain volume measure (in monetary terms) of the component $i$ in period $t$, $z_t$ the one of the total, and $y(t)$ the year of the period $t$. Within a year $y$, the chain volume measure of the total is exactly the sum of the chain volume measures of the components, valued at the relative prices $\rho_{i,y-1}$ of the previous year: $$ z_t = \sum_i \rho_{i,y(t)-1}\, x_{i,t}. $$ The relative price $\rho_{i,y}$ is the implicit price of the component $i$ over the implicit price of the total: * annual overlap (`method = "ao"`), with the annual sums $cp_{i,y}$, $x_{i,y}$, $cp_y$ and $z_y$ of the current prices and of the chain volume measures: $$ \rho_{i,y} = \frac{cp_{i,y} / x_{i,y}}{cp_y / z_y}; $$ * one-quarter overlap (`method = "oqo"`): the same ratio computed on the overlap period (the last quarter, or the last month, of year $y$), the current prices being valued at the average prices of the year (`cp_pi2cy()`). The contribution of the component $i$ to the growth between a period $s$ and a period $t$ (previous period, same period of the previous year, or previous year) is $$ C_{i,t} = 100 \left[\frac{(x_{i,t} - x_{i,s})\,\rho_{i,y(t)-1}}{z_s} + \left(\frac{x_{i,s}}{z_s} - a_{i,y(t)-1}\right) \left(\rho_{i,y(t)-1} - \rho_{i,y(s)-1}\right)\right] $$ where $a_{i,y}$ is the share of the component in the total: $a_{i,y} = x_{i,y} / z_y$ (annual sums) for the annual overlap, and the same share on the overlap period for the one-quarter overlap. Summing over $i$ gives $\sum_i C_{i,t} = 100\,(z_t / z_s - 1)$. The second term is zero if $s$ and $t$ are in the same year. For the annual overlap and the growth over the previous period, this is the formula of the example 8.9 of the manual. The formula for the one-quarter overlap, and for the growth over the same period of the previous year, derive from the same decomposition: they add up to the growth of the total exactly. The breakdown between the components is not unique, only its sum is: the second term (revaluation due to the change of relative prices) is allocated as in the manual. # Example `chain_laspeyres()` computes the chain volume measures of the components and of their total (last column): ```{r} x <- chain_laspeyres(imf_cp, imf_pi, method = "ao", base_year = 2010, output = "measure") round(x, 3) ``` Contributions to the growth over the previous quarter (`type = "period"`, the default). `extra` adds the growth of the total and the residual (growth of the total minus the sum of the contributions): ```{r} chain_contrib(x, imf_cp, method = "ao", extra = c("total", "residual")) |> round(3) ``` Contributions to the growth over the same quarter of the previous year: ```{r} chain_contrib(x, imf_cp, method = "ao", type = "yoy", extra = "total") |> round(3) ``` Contributions to the growth of the annual sums: ```{r} chain_contrib(x, imf_cp, method = "ao", type = "annual", extra = "total") |> round(3) ``` # One-quarter overlap ```{r} x_oqo <- chain_laspeyres(imf_cp, imf_pi, method = "oqo", base_year = 2010, output = "measure") chain_contrib(x_oqo, imf_cp, method = "oqo", type = "period", pi = imf_pi, extra = c("total", "residual")) |> round(3) ``` The overlap quarter is valued at the average prices of the year, as in the manual (`cp_pi2cy()`): `chain_contrib()` needs the price indices `pi` to do so (or `cp` already valued at these prices). With the one-quarter overlap technique, the contributions to the annual growth are only available from the second year (the annual sum of the base year is not defined). # Correspondence with the manual * annual overlap: `type = "period"` and `type = "annual"` are the equations (29) (quarters 2 to 4 and annual data) and (30) (first quarter) of the paragraphs 8.86-8.87, and `type = "yoy"` is the equation (31) of the paragraph 8.88. The example 8.9 is reproduced by the tests of the package; * one-quarter overlap: the manual (footnote 35) applies the same formulas with the annual deflators, but the contributions are then not exactly additive. The package provides this variant with `method = "ao"` applied to the one-quarter overlap measures, and an exactly additive version with `method = "oqo"`: ```{r oqo-manual} x_oqo <- chain_laspeyres(imf_cp, imf_pi, method = "oqo", base_year = 2010, output = "measure") # Formulas of the manual (annual deflators) chain_contrib(x_oqo, imf_cp, method = "ao", extra = "residual") |> round(4) # Deflators of the overlap period (valued at the average prices of the year) chain_contrib(x_oqo, imf_cp, method = "oqo", pi = imf_pi, extra = "residual") |> round(4) ``` * a variable that can be negative, zero or positive (changes in inventories) is treated residually (paragraph 8.90): its contribution is the difference between the contribution of the aggregate that includes it and the contributions of the other components. # Quarterly Fisher indices The paragraph 8.89 gives the contributions to the percent change of a quarterly Fisher index. `fisher_contrib()` takes the current prices of all the components and their price indices over the previous quarter (`pi_py2pp()` converts price indices over the previous year): ```{r fisher} ep8.4 <- pi_py2pp(imf_pi) fisher_contrib(imf_cp, ep8.4, extra = c("total", "residual")) |> round(3) ``` With $x_i^t$ the current price value of the component $i$ in period $t$, $z^t$ the one of the aggregate, $r_i = p_i^t / p_i^{t-1}$ the price index of the component over the previous period and $F$ the Fisher volume index of the aggregate (previous period = 1), the contribution of the component $i$ is $$ C_i^t = 100\, \frac{\dfrac{z^t}{z^{t-1}} \left(\dfrac{x_i^t}{r_i} - x_i^{t-1}\right) + F \left(x_i^t - x_i^{t-1} r_i\right)} {z^t + F \sum_j x_j^{t-1} r_j}. $$ This is the equation (32) of the manual. The decomposition is exact: the residual is zero up to numerical errors. As printed in the manual, the equation has the ratio $z^{t-1} / z^t$ in the first term and $x_i^{t-1} / r_i$ in the second one; with these ratios, the contributions do not add up to the percent change. The version implemented uses $z^t / z^{t-1}$ and $x_i^{t-1} r_i$ (consistent with the denominator). The adjustments that some countries add to the quarterly contributions (benchmarking of the quarterly indices, annual rates) are not done. # Non-additivity and residual Two different things must not be mixed up: * the chain volume measures are not additive: the chain measure of the total is not the sum of the chain measures of the components. `chain_discrepancy()` returns $D_t = \sum_i x_{i,t} - z_t$ (or $100\, D_t / z_t$ with `relative = TRUE`). It is zero in the base year and, with the annual overlap, in the year after; * the contributions take this into account and add up to the growth of the total. The residual (`extra = "residual"`) is therefore zero if the data are fully consistent, i.e. if the annual price indices are exactly those of the quarterly data. In the example of the manual, they are not (the residual is small, below 0.001 percentage point). ```{r} chain_discrepancy(x) |> round(3) chain_discrepancy(x, relative = TRUE) |> round(3) ``` # Monthly data The functions use the frequency of the series. As an illustration, each quarter of the data of the example is spread over three months (the contributions are then non-zero only for the first month of each quarter, when the quarter changes): ```{r} spread <- function(a, scale = 1) { m <- as.matrix(a) res <- ts(m[rep(seq_len(nrow(m)), each = 3), , drop = FALSE] * scale, start = c(start(a)[1], 1), frequency = 12) colnames(res) <- colnames(a) res } cp_m <- spread(imf_cp, 1 / 3) pi_m <- spread(imf_pi) x_m <- chain_laspeyres(cp_m, pi_m, method = "ao", base_year = 2010, output = "measure") chain_contrib(x_m, cp_m, method = "ao") |> window(start = c(2011, 1), end = c(2011, 8)) |> round(3) ``` # Variables that change sign Growth rates and chain volume measures are meaningless for a variable that can be negative, zero or positive, such as changes in inventories (paragraph 8.56 of the manual). Two solutions: * contributions are calculated residually (paragraph 8.90): the contribution of the variable is the difference between the contribution of the aggregate that includes it and the contributions of the other components; * a pseudo chain volume series is derived (paragraphs 8.57-8.58): the variable is written as the difference of two series that only take positive values (closing minus opening inventories, exports minus imports), each of them is chain-linked separately, and the chain volume series is their difference. `chain_pseudo()` does it, from the current prices and the price indices of the two series (the two products of the example below only stand in for them): ```{r pseudo} chain_pseudo(imf_cp[, "A"], imf_pi[, "A"], imf_cp[, "B"], imf_pi[, "B"], base_year = 2010) |> round(1) ``` # Change of the reference year `chain_rebase()` changes the reference year of an index or of a measure. With $b$ the new reference year and $\bar{I}_b$ the average of the index over its periods, the rebased index is $100\, I_t / \bar{I}_b$; a measure is multiplied by $cp_b / x_b$ (annual sums of the current prices and of the measure in year $b$). The growth rates are unchanged. ```{r} chain_laspeyres(imf_cp, imf_pi, base_year = 2010) |> chain_rebase(base_year = 2012) |> round(2) ``` # References * Chevalier, M. (2003), "Chain Fisher Volume Index Methodology", Statistics Canada. * International Monetary Fund (2018), *Quarterly National Accounts Manual (2017 Edition)*, Washington, DC. [doi:10.5089/9781475589870.069](https://doi.org/10.5089/9781475589870.069).