pricelevels {pricelevels} | R Documentation |
Spatial price indices
Description
Calculation of multiple spatial price indices at once.
Usage
# list all available price indices:
list.indices()
# compute all price indices:
pricelevels(p, r, n, q=NULL, w=NULL, base=NULL, 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. If |
settings |
A list of control settings to be used. The following settings are supported:
|
Details
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
A matrix of price levels where the rows contain the index methods and the columns the regions.
Author(s)
Sebastian Weinand
Examples
# sample complete price data:
set.seed(123)
dt1 <- rdata(R=3, B=1, N=5)
# compute unweighted indices:
dt1[, pricelevels(p=price, r=region, n=product, base="1")]
# compute all indices relying on quantities:
dt1[, pricelevels(p=price, r=region, n=product, q=quantity, base="1")]
# 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 unweighted indices:
dt[, pricelevels(p=price, r=region, n=product, base="1")]
# change base region:
dt[, pricelevels(p=price, r=region, n=product, base="4")]