https://github.com/marberts/piar
Price index aggregation in R
https://github.com/marberts/piar
cran economics inflation official-statistics r r-package rstats statistics
Last synced: 11 months ago
JSON representation
Price index aggregation in R
- Host: GitHub
- URL: https://github.com/marberts/piar
- Owner: marberts
- License: other
- Created: 2021-05-26T02:58:35.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-05-06T13:46:21.000Z (about 2 years ago)
- Last Synced: 2024-05-07T04:29:44.120Z (about 2 years ago)
- Topics: cran, economics, inflation, official-statistics, r, r-package, rstats, statistics
- Language: R
- Homepage: https://marberts.github.io/piar/
- Size: 9.04 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
```
# Price Index Aggregation in R 
[](https://cran.r-project.org/package=piar)
[](https://marberts.r-universe.dev/piar)
[](https://anaconda.org/conda-forge/r-piar)
[](https://github.com/marberts/piar/actions)
[](https://app.codecov.io/gh/marberts/piar)
[](https://zenodo.org/doi/10.5281/zenodo.10110046)
[](https://github.com/SNStatComp/awesome-official-statistics-software)
[](https://doi.org/10.21105/joss.06781)
Most price indexes are made with a two-step procedure, where period-over-period *elemental indexes* are first calculated for a collection of *elemental aggregates* at each point in time, and then aggregated according to a *price index aggregation structure*. These indexes can then be chained together to form a time series that gives the evolution of prices with respect to a fixed base period. This package contains a collection of functions that revolve around this work flow, making it easy to build standard price indexes, and implement the methods described by Balk (2008), von der Lippe (2007), and the CPI manual (2020) / PPI manual (2004) for bilateral price indexes.
The tools in this package are designed to be useful for both researching new
sources of data and methods to construct price indexes, and the regular
production of price statistics. It is targeted towards economists,
statisticians, and data scientists working at national statistical agencies,
central banks, financial institutions, and in academia that want to measure and
study the evolution of prices over time.
## Installation
Get the stable version from CRAN.
```{r, eval=FALSE}
install.packages("piar")
```
The development version can be installed from R-Universe
```{r, eval=FALSE}
install.packages("piar", repos = c("https://marberts.r-universe.dev", "https://cloud.r-project.org"))
```
or directly from Github.
```{r, eval=FALSE}
pak::pak("marberts/piar")
```
## Usage
There are several detailed vignette showing how to use **piar**: `browseVignettes("piar")`. But the basic work flow is fairly simple.
The starting point is to make period-over-period elemental price indexes with the `elemental_index()` function.
```{r}
library(piar)
# Make Jevons business-level elemental indexes
head(ms_prices)
elementals <- ms_prices |>
transform(
relative = price_relative(price, period = period, product = product)
) |>
elemental_index(relative ~ period + business, na.rm = TRUE)
elementals
```
And an aggregation structure.
```{r}
# Make an aggregation structure from businesses to higher-level
# industrial classifications
ms_weights
ms_weights[c("level1", "level2")] <-
expand_classification(ms_weights$classification)
pias <- ms_weights[c("level1", "level2", "business", "weight")]
pias
```
The `aggregate()` method can then be used to aggregate the elemental indexes according to the aggregation structure (the first three rows below) and fill in missing elemental indexes while maintaining consistency in aggregation. There are a variety of methods to work with these index objects, such as chaining them over time.
```{r}
# Aggregate elemental indexes with an arithmetic index
index <- aggregate(elementals, pias, na.rm = TRUE)
# Chain them to get a time series
chain(index)
```
## Contributing
All contributions are welcome. Please start by opening an issue on GitHub to report any bugs or suggest improvements and new features. See the contribution
guidelines for this project for more information.
## References
Balk, B. M. (2008). *Price and Quantity Index Numbers*. Cambridge University Press.
Chiru, R., Huang, N., Lequain, M. Smith, P., and Wright, A. (2015). *The Canadian Consumer Price Index Reference Paper*, Statistics Canada catalogue 62-553-X. Statistics Canada.
ILO, IMF, UNECE, OECD, and World Bank. (2004). *Producer Price Index Manual: Theory and Practice*. International Monetary Fund.
IMF, ILO, Eurostat, UNECE, OECD, and World Bank. (2020). *Consumer Price Index Manual: Concepts and Methods*. International Monetary Fund.
von der Lippe, P. (2007). *Index Theory and Price Statistics*. Peter Lang.