GEKS_decomp: Decomposition of GEKS-tornqvist

Description Usage Arguments Value Examples

View source: R/GEKS_decomp.R

Description

Take smiliar inputs as the GEKS function and return the decomposition on the multilateral scale.

Usage

1
GEKS_decomp(times, price, id, weight, custom_time = c(), window_length = NULL)

Arguments

times

vector of the times at which price observations were made.
NOTE: times must be of class Date or numeric.

price

vector of log of prices at the given time

id

vector of distinct identification number of consumer goods

weight

vector of expenditure weights used in the regressions

custom_time

either empty (will assume latest periods) or a vector of length two relating to times compared where [1] is the 'start_time' time and [2] is the 'to' time e.g Comparing contribution start_time "1973-04-01" to "1973-05-01" would be c("1973-04-01", "1973-05-01")

window_length

optional. Single number for length of window for the data that regressions are fit on. Note if window_length is present it assumes custom time is latest two periods in window.

Value

A dataframe containing the numeric contribution (contrib) of every price observation in the window, the product of which will (roughly) equal the index movement between the two time periods. p_contrib is the standardised percentage contribution of the observation, the sum of which will equal 1.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(TPDdecomp)

contributions <- with(
    turvey,
    GEKS_decomp(times = month,
               price = price,
               id = commodity,
               weight = price*quantity,
               custom_time = as.Date(c("1973-04-30","1973-05-31")),
               window_length = NULL)
 )


str(contributions)
Classesdata.tableand 'data.frame':	5 obs. of  5 variables:
$ from     : Date, format: "1973-04-30" "1973-04-30" "1973-04-30" ...
$ to       : Date, format: "1973-05-31" "1973-05-31" "1973-05-31" ...
$ id       : Factor w/ 5 levels "Apples","Grapes",..: 1 2 3 4 5
$ contrib  : num  1.035 0.998 1.017 1.034 1
$ p_contrib: num  0.411 -0.02 0.206 0.403 0

MjStansfi/GEKSdecomp documentation built on Sept. 30, 2020, 4:21 p.m.