Working with Index Numbers (original) (raw)
IndexNumberTools intends to ease the everyday work of users and producers of index numbers by providing functionalities like chain-linking, base shifting or computing pyp indices.
Installation
Getting started
We’ll work through an example using the Spanish GDP in current prices, which is preloaded as gdp_current
, and the chain-linked volume (index), gdp_volume
.
We can easily re-reference the volume series with [change_ref_year()](reference/change%5Fref%5Fyear.html)
.1
#> Time Series:
#> Start = 2008
#> End = 2022
#> Frequency = 1
#> 2020 2010
#> 2008 104.90885 103.81798
#> 2009 100.95573 99.90596
#> 2010 101.05075 100.00000
#> 2011 100.40412 99.36010
#> 2012 97.52742 96.51331
#> 2013 96.13535 95.13571
#> 2014 97.59707 96.58224
#> 2015 101.56035 100.50430
#> 2016 104.52100 103.43417
#> 2017 107.54800 106.42969
#> 2018 110.12422 108.97913
#> 2019 112.28397 111.11642
#> 2020 100.00000 98.96018
#> 2021 106.68315 105.57383
#> 2022 113.27545 112.09758
We can also get the series at previous year prices from gdp_volume
with [get_pyp()](reference/get%5Fpyp.html)
.2
Multiplying the volume series by the mean of the current prices series at the reference year (2020), we obtain the GDP in (chain-linked) constant prices.
ref_year_mean <- window(gdp_current,start = c(2020,1), end = c(2020,4)) |> mean()
gdp_constant <- ref_year_mean * gdp_volume / 100
By dividing the GDP in current prices by the GDP in constant prices, we derive the chain-linked implicit deflator of the GDP.
gdp_deflator <- gdp_current / gdp_constant * 100
Using [get_v_index()](reference/get%5Fv%5Findex.html)
and chain-linking the result with [get_chain_linked()](reference/get%5Fchain%5Flinked.html)
, we get the chain-linked value indices.
Then, we can verify the identity V=P⋅QV = P\cdot Q, that is, the value index must equal the product of the price and volume indices.
dplyr::near(gdp_value, gdp_deflator * gdp_volume / 100) |> all()
#> [1] TRUE