pb_index: Bilateral Price Indexes

Description Usage Arguments Value Examples

View source: R/pb_index.R

Description

Bilateral indexes refer to the case when only two periods are compared each time. pb_index() computes price indexes in a bilateral approach.

Usage

1
pb_index(df, p, qty, id, tm, typ = "f", seq = "ch", bsk = "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 "f" for Fisher price indexes (by default), "t" for Tornqvist price indexes, "l" for Laspeyres price indexes, and "p" for Paasche price indexes.

seq

Index construction sequences when the number of periods is larger than 2. Options include "ch" for chained indexes (by default), and "fb" for fixed base indexes.

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.

Value

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

Examples

1
2
3
4
5
6
7
8
9
# Use the built-in data set "prices"
# Laspeyres fixed base indexes with a constant basket
df <- prices[[1]]
df <- df[order(df[,"t"]),]
index1 <- pb_index(df, "p", "q", "id", "t", typ = "l", seq = "fb", bsk = "cst")
# Fisher chained indexes with a flexible basket
df <- prices[[2]]
df <- df[order(df[,"t"]),]
index2 <- pb_index(df, "p", "q", "id", "t")

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