-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
123 lines (84 loc) · 4.73 KB
/
README.Rmd
File metadata and controls
123 lines (84 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file. -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
```
# Price Index Aggregation in R <a href="https://marberts.github.io/piar/"><img src="man/figures/logo.png" align="right" height="139" alt="piar website" /></a>
<!-- badges: start -->
[](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)
<!-- badges: end -->
Most price indexes are made with a two-step procedure, where period-over-period *elementary indexes* are first calculated for a collection of *elementary 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 elementary price indexes with the `elementary_index()` function.
```{r}
library(piar)
# Make Jevons business-level elementary indexes
head(ms_prices)
elementals <- ms_prices |>
transform(
relative = price_relative(price, period = period, product = product)
) |>
elementary_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 elementary indexes according to the aggregation structure (the first three rows below) and fill in missing elementary 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 elementary 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.
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.