geks {pricelevels} | R Documentation |
GEKS method
Description
Function index.pairs()
computes bilateral index numbers for all pairs of regions. Based on that, function geks()
derives regional price levels using the GEKS method proposed by Gini (1924, 1931), Elteto and Koves (1964), and Szulc (1964).
Usage
index.pairs(p, r, n, q=NULL, w=NULL, settings=list())
geks(p, r, n, q=NULL, w=NULL, base=NULL, simplify=TRUE, settings=list())
Arguments
p |
A numeric vector of prices. |
r , n |
A character vector or factor of regional entities |
q , w |
A numeric vector of non-negative quantities |
base |
A character specifying the base region to which all price levels are expressed. When |
simplify |
A logical indicating whether the full regression-object should be provided ( |
settings |
A list of control settings to be used. The following settings are supported:
|
Details
The GEKS index is a two-step approach. First, prices are aggregated into bilateral index numbers using the index given in type
. This is done for all pairs of regions via function index.pairs()
. Second, these bilateral index numbers are transformed into a set of multilateral, transitive index numbers.
Note that the quantities q
or weights w
are used within the aggregation of prices into index numbers (first stage) while the subsequent transformation of these index numbers (second stage) usually does not rely on any weights (but can if specified in settings$wmethod
).
Before calculations start, missing values are excluded and duplicated observations for r
and n
are aggregated, that is, duplicated prices p
and weights w
are averaged and duplicated quantities q
added up.
The weights w
must represent expenditure shares defined as w_i^r = p_i^r q_i^r / \sum_{j=1}^{N} p_j^r q_j^r
. They are internally (re-)normalized such that they add up to 1 for each region r
.
Value
For index.pairs()
, a data.table with variables base
(the base region), region
(the comparison region), and eval(settings$type)
(the price level between the two regions).
For geks()
, a named vector or matrix of (unlogged) regional price levels if simplify=TRUE
. Otherwise, for simplify=FALSE
, a lm
-object containing the full regression output.
Author(s)
Sebastian Weinand
References
Gini, C. (1924). Quelques Considerations au Sujet de la Construction des Nombres Indices des Prix et des Questions Analogues. Mentron, 4 (1), 3-162.
Gini, C. (1931). On the Circular Test of Index Numbers. International Statistical Review, 9 (2), 3-25.
Elteto, O. and Koves, P. (1964). On a Problem of Index Number Computation Relating to International Comparison. Statisztikai Szemle, 42, 507-518.
Szulc, B. J. (1964). Indices for Multiregional Comparisons. Przeglad Statystyczny, 3, 239-254.
See Also
Examples
# example data:
set.seed(123)
dt1 <- rdata(R=3, B=1, N=5)
### Index pairs
# matrix of bilateral index numbers:
Pje <- dt1[, index.pairs(p=price, r=region, n=product, settings=list(type="jevons"))]
# if the underlying index satisfies the country-reversal
# test (like the Jevons index), the price index numbers of
# the upper-right triangle are the same as the inverse of
# the price index numbers of the lower-left triangle.
all.equal(Pje$jevons[3], 1/Pje$jevons[7]) # true
# hence, one could set all.pairs=FALSE without loosing any
# information. however, this is no longer true for indices
# that do not satisfy this test (like the Carli index):
Pca <- dt1[, index.pairs(p=price, r=region, n=product, settings=list(type="carli"))]
all.equal(Pca$carli[3], 1/Pca$carli[7]) # false
### GEKS method
# for complete price data (no gaps), the jevons index is transitive.
# hence, no adjustment is needed by the geks approach, which is
# why the index numbers are the same:
all.equal(
dt1[, geks(p=price, r=region, n=product, base="1", settings=list(type="jevons"))],
dt1[, jevons(p=price, r=region, n=product, base="1")]
) # true
# this is no longer true when there are gaps in the data:
dt1.gaps <- dt1[!rgaps(region, product, amount=0.25), ]
all.equal(
dt1.gaps[, geks(p=price, r=region, n=product, base="1", settings=list(type="jevons"))],
dt1.gaps[, jevons(p=price, r=region, n=product, base="1")]
) # now, differences
# weighting at the second step of GEKS can be done with respect
# to the intersection of products for each pair of region:
dt1.gaps[, geks(p=price, r=region, n=product, base="1",
settings=list(type="jevons", wmethod="obs"))]
# add price data:
dt2 <- rdata(R=4, B=1, N=4)
dt2[, "region":=factor(region, labels=4:7)]
dt2[, "product":=factor(product, labels=6:9)]
dt <- rbind(dt1, dt2)
dt[, is.connected(r=region, n=product)] # non-connected now
# compute all index pairs and geks:
require(data.table)
as.matrix(dcast(
data=dt[, index.pairs(p=price, r=region, n=product)],
formula=base~region,
value.var="jevons"), rownames="base")
dt[, geks(p=price, r=region, n=product, base="1", settings=list(type="jevons"))]