gpindex
An R package for calculating generalized price and quantity indexes
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 1 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.8%) to scientific vocabulary
Keywords
cran
economics
inflation
official-statistics
r
r-package
rstats
statistics
Last synced: 6 months ago
·
JSON representation
·
Repository
An R package for calculating generalized price and quantity indexes
Basic Info
- Host: GitHub
- Owner: marberts
- License: other
- Language: R
- Default Branch: main
- Homepage: https://marberts.github.io/gpindex/
- Size: 11.7 MB
Statistics
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 1
- Releases: 5
Topics
cran
economics
inflation
official-statistics
r
r-package
rstats
statistics
Created almost 6 years ago
· Last pushed 9 months ago
Metadata Files
Readme
Changelog
License
Citation
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
```
# Generalized Price and Quantity Indexes
[](https://cran.r-project.org/package=gpindex)
[](https://marberts.r-universe.dev/gpindex)
[](https://anaconda.org/conda-forge/r-gpindex)
[](https://github.com/marberts/gpindex/actions)
[](https://app.codecov.io/gh/marberts/gpindex)
[](https://zenodo.org/doi/10.5281/zenodo.10097742)
Tools to build and work with bilateral generalized-mean price indexes (and by extension quantity indexes), and indexes composed of generalized-mean indexes (e.g., superlative quadratic-mean indexes, GEKS). Covers the core mathematical machinery for making bilateral price indexes, computing price relatives, detecting outliers, and decomposing indexes, with wrappers for all common (and many uncommon) index-number formulas. Implements and extends many of the methods in Balk (2008), von der Lippe (2007), and the CPI manual (2020).
## Installation
Get the stable release from CRAN.
```{r, eval = FALSE}
install.packages("gpindex")
```
The development version can be installed from R-Universe
```{r, eval = FALSE}
install.packages("gpindex", repos = c("https://marberts.r-universe.dev", "https://cloud.r-project.org"))
```
or directly from GitHub.
```{r, eval = FALSE}
pak::pak("marberts/gpindex")
```
## Usage
```{r}
library(gpindex)
# Start with some data on prices and quantities for 6 products
# over 5 periods.
price6
quantity6
# We'll only need prices and quantities for a few periods.
p1 <- price6[[1]]
p2 <- price6[[2]]
p3 <- price6[[3]]
q1 <- price6[[1]]
q2 <- price6[[2]]
# There are functions to calculate all common price indexes,
# like the Laspeyres and Paasche index.
laspeyres_index(p2, p1, q1)
paasche_index(p2, p1, q2)
# The underlying mean functions are also available, as usually
# only price relatives and weights are known.
s1 <- p1 * q1
s2 <- p2 * q2
arithmetic_mean(p2 / p1, s1)
harmonic_mean(p2 / p1, s2)
# The mean representation of a Laspeyres index makes it easy to
# chain by price-updating the weights.
laspeyres_index(p3, p1, q1)
arithmetic_mean(p2 / p1, s1) *
arithmetic_mean(p3 / p2, update_weights(p2 / p1, s1))
# The mean representation of a Paasche index makes it easy to
# calculate percent-change contributions.
harmonic_contributions(p2 / p1, s2)
# The ideas are the same for more exotic indexes,
# like the Lloyd-Moulton index.
# Let's start by making some functions for the Lloyd-Moulton index
# when the elasticity of substitution is -1 (an output index).
lloyd_moulton <- lm_index(-1)
quadratic_mean <- generalized_mean(2)
quadratic_update <- factor_weights(2)
quadratic_contributions <- contributions(2)
# This index can be calculated as a mean of price relatives.
lloyd_moulton(p2, p1, q1)
quadratic_mean(p2 / p1, s1)
# Chained over time
lloyd_moulton(p3, p1, q1)
quadratic_mean(p2 / p1, s1) *
quadratic_mean(p3 / p2, quadratic_update(p2 / p1, s1))
# And decomposed to get the contributions of each relative.
quadratic_contributions(p2 / p1, s1)
```
## Prior work
There are a number of R packages on the CRAN that implement the standard index-number formulas (e.g., **IndexNumber**, **productivity**, **IndexNumR**, **micEconIndex**, **PriceIndices**). While there is support for a large number of index-number formulas out-of-the box in this package, the focus is on the tools to easily make and work with any type of generalized-mean price index. Consequently, compared to existing packages, this package is suitable for building custom price/quantity indexes, calculating indexes with sample data, decomposing indexes, and learning about or researching different types of index-number formulas.
## References
Balk, B. M. (2008). *Price and Quantity Index Numbers*. Cambridge University Press.
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.
Owner
- Name: Steve Martin
- Login: marberts
- Kind: user
- Location: Ottawa, Canada
- Company: Government of Canada
- Repositories: 6
- Profile: https://github.com/marberts
I build tools to measure inflation :chart_with_upwards_trend:
Citation (CITATION.cff)
# --------------------------------------------
# CITATION file created with {cffr} R package
# See also: https://docs.ropensci.org/cffr/
# --------------------------------------------
cff-version: 1.2.0
message: 'To cite package "gpindex" in publications use:'
type: software
license: MIT
title: 'gpindex: Generalized Price and Quantity Indexes'
version: 0.6.3
doi: 10.5281/zenodo.10097742
identifiers:
- type: doi
value: 10.32614/CRAN.package.gpindex
abstract: Tools to build and work with bilateral generalized-mean price indexes (and
by extension quantity indexes), and indexes composed of generalized-mean indexes
(e.g., superlative quadratic-mean indexes, GEKS). Covers the core mathematical machinery
for making bilateral price indexes, computing price relatives, detecting outliers,
and decomposing indexes, with wrappers for all common (and many uncommon) index-number
formulas. Implements and extends many of the methods in Balk (2008, <https://doi.org/10.1017/CBO9780511720758>),
von der Lippe (2007, <https://doi.org/10.3726/978-3-653-01120-3>), and the CPI manual
(2020, <https://doi.org/10.5089/9781484354841.069>).
authors:
- family-names: Martin
given-names: Steve
email: marberts@protonmail.com
orcid: https://orcid.org/0000-0003-2544-9480
preferred-citation:
type: manual
title: 'gpindex: Generalized Price and Quantity Indexes'
authors:
- family-names: Martin
given-names: Steve
orcid: https://orcid.org/0000-0003-2544-9480
email: marberts@protonmail.com
year: '2025'
doi: 10.5281/zenodo.10097742
url: https://cran.r-project.org/package=gpindex
notes: R package version 0.6.3
repository: https://CRAN.R-project.org/package=gpindex
repository-code: https://github.com/marberts/gpindex
url: https://marberts.github.io/gpindex/
contact:
- family-names: Martin
given-names: Steve
email: marberts@protonmail.com
orcid: https://orcid.org/0000-0003-2544-9480
keywords:
- cran
- economics
- inflation
- official-statistics
- r
- r-package
- rstats
- statistics
references:
- type: software
title: 'R: A Language and Environment for Statistical Computing'
notes: Depends
url: https://www.R-project.org/
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2025'
version: '>= 4.1'
- type: software
title: stats
abstract: 'R: A Language and Environment for Statistical Computing'
notes: Imports
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2025'
- type: software
title: knitr
abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R'
notes: Suggests
url: https://yihui.org/knitr/
repository: https://CRAN.R-project.org/package=knitr
authors:
- family-names: Xie
given-names: Yihui
email: xie@yihui.name
orcid: https://orcid.org/0000-0003-0645-5666
year: '2025'
doi: 10.32614/CRAN.package.knitr
- type: software
title: quarto
abstract: 'quarto: R Interface to ''Quarto'' Markdown Publishing System'
notes: Suggests
url: https://quarto-dev.github.io/quarto-r/
repository: https://CRAN.R-project.org/package=quarto
authors:
- family-names: Allaire
given-names: JJ
email: jj@posit.co
orcid: https://orcid.org/0000-0003-0174-9868
- family-names: Dervieux
given-names: Christophe
email: cderv@posit.co
orcid: https://orcid.org/0000-0003-4474-2498
year: '2025'
doi: 10.32614/CRAN.package.quarto
- type: software
title: testthat
abstract: 'testthat: Unit Testing for R'
notes: Suggests
url: https://testthat.r-lib.org
repository: https://CRAN.R-project.org/package=testthat
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
year: '2025'
doi: 10.32614/CRAN.package.testthat
version: '>= 3.0.0'
GitHub Events
Total
- Create event: 1
- Release event: 1
- Issues event: 10
- Watch event: 1
- Issue comment event: 5
- Push event: 46
- Pull request event: 10
- Fork event: 1
Last Year
- Create event: 1
- Release event: 1
- Issues event: 10
- Watch event: 1
- Issue comment event: 5
- Push event: 46
- Pull request event: 10
- Fork event: 1
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Steve Martin | s****1@g****m | 383 |
| Anthony Savagar | a****r | 1 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 10
- Total pull requests: 16
- Average time to close issues: 2 months
- Average time to close pull requests: about 4 hours
- Total issue authors: 1
- Total pull request authors: 2
- Average comments per issue: 0.1
- Average comments per pull request: 0.63
- Merged pull requests: 12
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 6
- Pull requests: 16
- Average time to close issues: 2 days
- Average time to close pull requests: about 4 hours
- Issue authors: 1
- Pull request authors: 2
- Average comments per issue: 0.0
- Average comments per pull request: 0.63
- Merged pull requests: 12
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- marberts (10)
Pull Request Authors
- marberts (13)
- asavagar (2)
Top Labels
Issue Labels
enhancement (5)
documentation (3)
bug (3)
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 387 last-month
- Total dependent packages: 2
- Total dependent repositories: 1
- Total versions: 17
- Total maintainers: 1
cran.r-project.org: gpindex
Generalized Price and Quantity Indexes
- Homepage: https://marberts.github.io/gpindex/
- Documentation: http://cran.r-project.org/web/packages/gpindex/gpindex.pdf
- License: MIT + file LICENSE
-
Latest release: 0.6.3
published 9 months ago
Rankings
Dependent packages count: 17.6%
Downloads: 19.8%
Average: 23.1%
Dependent repos count: 24.3%
Stargazers count: 25.7%
Forks count: 28.0%
Maintainers (1)
Last synced:
6 months ago