Title: | Price and Quantity Indices |
---|---|
Description: | Tools for calculating Laspeyres, Paasche, and Fisher price and quantity indices. |
Authors: | Arne Henningsen |
Maintainer: | Arne Henningsen <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1-8 |
Built: | 2024-10-24 03:28:29 UTC |
Source: | https://github.com/cran/micEconIndex |
Calculates a Laspeyres, Paasche or Fisher price index.
priceIndex( prices, quantities, base, data, method = "Laspeyres", na.rm = FALSE, weights = FALSE )
priceIndex( prices, quantities, base, data, method = "Laspeyres", na.rm = FALSE, weights = FALSE )
prices |
Vector that contains the names of the prices. |
quantities |
Vector that contains the names of the quantities that
belong to the |
base |
The base period(s) to calculate the indices (see details). |
data |
Dataframe that contains the prices and quantities. |
method |
Which price index: "Laspeyres", "Paasche" or "Fisher". |
na.rm |
a logical value passed to ' |
weights |
logical. Should an attribute 'weights' that contains the relatives weights of each quantity be added? |
The argument base
can be either
(a) a single number: the row number of the base prices and quantities,
(b) a vector indicating several observations: The means of these
observations are used as base prices and quantities, or
(c) a logical vector with the same length as the data
: The
means of the observations indicated as 'TRUE' are used as base prices
and quantities.
If any values used for calculating the price index (e.g. current quantities, base quantities, current prices or base prices) are not available (NA), they are ignored (only) if they are multiplied by zero.
a vector containing the price indices.
Arne Henningsen
if( requireNamespace( 'micEcon', quietly = TRUE ) ) { data( Missong03E7.7, package = "micEcon" ) # Laspeyres Price Indices priceIndex( c( "p.beef", "p.veal", "p.pork" ), c( "q.beef", "q.veal", "q.pork" ), 1, Missong03E7.7 ) # Paasche Price Indices priceIndex( c( "p.beef", "p.veal", "p.pork" ), c( "q.beef", "q.veal", "q.pork" ), 1, Missong03E7.7, "Paasche" ) data( Bleymueller79E25.1, package = "micEcon" ) # Laspeyres Price Indices priceIndex( c( "p.A", "p.B", "p.C", "p.D" ), c("q.A", "q.B", "q.C", "q.D" ), 1, Bleymueller79E25.1 ) # Paasche Price Indices priceIndex( c( "p.A", "p.B", "p.C", "p.D" ), c("q.A", "q.B", "q.C", "q.D" ), 1, Bleymueller79E25.1, "Paasche" ) }
if( requireNamespace( 'micEcon', quietly = TRUE ) ) { data( Missong03E7.7, package = "micEcon" ) # Laspeyres Price Indices priceIndex( c( "p.beef", "p.veal", "p.pork" ), c( "q.beef", "q.veal", "q.pork" ), 1, Missong03E7.7 ) # Paasche Price Indices priceIndex( c( "p.beef", "p.veal", "p.pork" ), c( "q.beef", "q.veal", "q.pork" ), 1, Missong03E7.7, "Paasche" ) data( Bleymueller79E25.1, package = "micEcon" ) # Laspeyres Price Indices priceIndex( c( "p.A", "p.B", "p.C", "p.D" ), c("q.A", "q.B", "q.C", "q.D" ), 1, Bleymueller79E25.1 ) # Paasche Price Indices priceIndex( c( "p.A", "p.B", "p.C", "p.D" ), c("q.A", "q.B", "q.C", "q.D" ), 1, Bleymueller79E25.1, "Paasche" ) }
Calculates a Laspeyres, Paasche or Fisher Quantity index.
quantityIndex( prices, quantities, base, data, method = "Laspeyres", na.rm = FALSE, weights = FALSE )
quantityIndex( prices, quantities, base, data, method = "Laspeyres", na.rm = FALSE, weights = FALSE )
prices |
Vector that contains the names of the prices. |
quantities |
Vector that contains the names of the quantities that
belong to the |
base |
The base period(s) to calculate the indices (see details). |
data |
Dataframe that contains the prices and quantities. |
method |
Which quantity index: "Laspeyres", "Paasche" or "Fisher". |
na.rm |
a logical value passed to ' |
weights |
logical. Should an attribute 'weights' that contains the relatives weights of each quantity be added? |
The argument base
can be either
(a) a single number: the row number of the base prices and quantities,
(b) a vector indicating several observations: The means of these
observations are used as base prices and quantities, or
(c) a logical vector with the same length as the data
: The
means of the observations indicated as 'TRUE' are used as base prices
and quantities.
If any values used for calculating the quantity index (e.g. current quantities, base quantities, current prices or base prices) are not available (NA), they are ignored (only) if they are multiplied by zero.
a vector containing the quantity indices.
Arne Henningsen
if( requireNamespace( 'micEcon', quietly = TRUE ) ) { data( Missong03E7.7, package = "micEcon" ) # Laspeyres Quantity Indices quantityIndex( c( "p.beef", "p.veal", "p.pork" ), c( "q.beef", "q.veal", "q.pork" ), 1, Missong03E7.7 ) # Paasche Quantity Indices quantityIndex( c( "p.beef", "p.veal", "p.pork" ), c( "q.beef", "q.veal", "q.pork" ), 1, Missong03E7.7, "Paasche" ) data( Bleymueller79E25.1, package = "micEcon" ) # Laspeyres Quantity Indices quantityIndex( c( "p.A", "p.B", "p.C", "p.D" ), c("q.A", "q.B", "q.C", "q.D" ), 1, Bleymueller79E25.1 ) # Paasche Quantity Indices quantityIndex( c( "p.A", "p.B", "p.C", "p.D" ), c("q.A", "q.B", "q.C", "q.D" ), 1, Bleymueller79E25.1, "Paasche" ) }
if( requireNamespace( 'micEcon', quietly = TRUE ) ) { data( Missong03E7.7, package = "micEcon" ) # Laspeyres Quantity Indices quantityIndex( c( "p.beef", "p.veal", "p.pork" ), c( "q.beef", "q.veal", "q.pork" ), 1, Missong03E7.7 ) # Paasche Quantity Indices quantityIndex( c( "p.beef", "p.veal", "p.pork" ), c( "q.beef", "q.veal", "q.pork" ), 1, Missong03E7.7, "Paasche" ) data( Bleymueller79E25.1, package = "micEcon" ) # Laspeyres Quantity Indices quantityIndex( c( "p.A", "p.B", "p.C", "p.D" ), c("q.A", "q.B", "q.C", "q.D" ), 1, Bleymueller79E25.1 ) # Paasche Quantity Indices quantityIndex( c( "p.A", "p.B", "p.C", "p.D" ), c("q.A", "q.B", "q.C", "q.D" ), 1, Bleymueller79E25.1, "Paasche" ) }