pm_index: Multilateral Price Indexes

Description Usage Arguments Value Examples

View source: R/pm_index.R

Description

Multilateral indexes refer to the case when more than two periods are compared each time. pm_index() computes price indexes in a multilateral approach.

Usage

1
2
pm_index(df, p, qty, id, tm, typ = "geks", len = NULL,
lnk = NULL, bsk = "flx", wd = "flx")

Arguments

df

A data frame sorted by the time period column.

p

A string indicating the price column.

qty

A string indicating the quantity column.

id

A string indicating the identity column.

tm

A string indicating the time period column. Each period must contain two observations at least.

typ

Relevant types of price indexes. Options include "geks" for GEKS price indexes (by default), "ccdi" for CCDI price indexes, "wtpd" for the weighted time product dummy method, and "gk" for the Geary-Khamis method.

len

Window length for linked indexes using rolling windows. A single window is set as NULL (by default).

lnk

Linking position in rolling windows, effective when 'len' is not NULL. If no linking position is provided, it should be set as NULL (by default). Other options include "mean" for mean splices and numbers for specific cases.

bsk

The choice of baskets when items are not matched over multiple periods. Options include "flx" (by default) for a flexible basket that varies depending on the maximal number of matched items in two periods each time, and "cst" for a constant basket that takes the maximal number of matched items across all periods.

wd

The choice of windows when items are not matched over multiple windows. Options include "flx" (by default) for a flexible window that allows for different items in two windows each time, and "cst" for a constant window that takes the maximal number of matched items across all windows.

Value

A data frame consisting of the time period and price indexes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Use the built-in data set "prices"
# matched items
df <- prices[[1]]
df <- df[order(df[,"t"]),]
# GEKS price indexes with a constant basket over periods
index1 <- pm_index(df, "p", "q", "id", "t", typ = "geks", bsk = "cst")
# unmatched items
df_add <- matrix(c(1, 6, 12, 5, 6, 7, 0.5, 0.5, 0.5, 9, 9, 9), nrow=3)
df_add <- as.data.frame(df_add)
colnames(df_add) <- colnames(df)
df <- rbind(df, df_add)
df <- df[order(df[,"t"]),]
# CCDI price indexes with a flexible basket over periods
index2 <- pm_index(df, "p", "q", "id", "t", typ = "ccdi", bsk = "flx")
# CCDI price indexes with rolling windows (window length at 11, linking at the first observation)
index3 <- pm_index(df, "p", "q", "id", "t", typ = "ccdi", len = 11, lnk = 1)
# CCDI price indexes with rolling windows (window length at 11, linking with mean splices)
index4 <- pm_index(df, "p", "q", "id", "t", typ = "ccdi", len = 11, lnk = "mean")

dfvad documentation built on Oct. 15, 2021, 5:16 p.m.