GEKS: GEKS-tornqvist

Description Usage Arguments Details Value Examples

View source: R/user_GEKS.R

Description

Takes a time series of prices and id's and returns an index using the GEKS method.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
GEKS(
  times,
  price,
  id,
  features = NULL,
  window_length,
  weight = NULL,
  splice_pos = "mean",
  index_method = "tornqvist",
  num_cores = 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

features

required if calculating 'impute-tornqvist'. Data.frame of features.

window_length

single number for length of windows of the data that regressions are fit on

weight

vector of expenditure weights used in the regressions

splice_pos

The position on which to splice the windows together. This can be a number from 1 to window_length or any of c("window", "half","movement", "mean").

index_method

A character string to select the index number method. Valid index number methods are fisher, tornqvist, impute-tronqvist. The default is tornqvist. (see ?IndexNumR::GEKSIndex)

num_cores

Number of cores to use for parallel computation. Convention is parallel::detectCores()-1 on local machines

Details

The function takes vectors for each of the inputs. It is important to note that the times argument must be of numeric or Date class. This is because the order of the dates matters.

The function also has the capability to run in parallel, using the num_cores argument. Note that for smaller datasets using non-parallel code is often faster than using parallelisation due to the overhead associated with dividing the job across multiple processors.

Value

The function returns a list of 3 items:

geks

a dataframe of the GEKS index

fixed_effects

a dataframe of the unspliced coefficients of the fixed effects model. The number of rows in the data frame is window_length * the number of windows in the data

diagnostics

a dataframe of diagnostic results produced during model calculation. The diagnostics dataframe has the following columns:

contrib_rids_pc

the % of ids which exist in the window and contribute to the index i.e. the id has at least 2 prices in the window

contrib_rids_nm

the number of ids which exist in the window that contribute

total_rids_in_data

number of ids in the entire dataset

total_rids_in_window

number of ids which have any prices in the window

num_records_in_window

The number of rows of data in this window

QU_1st

25% of the id's have less than this many prices in the window

gm_mean_entries_per_rid

the geometric mean number of prices per id in this window

mean_entries_per_rid

the mean number of prices per rid in this window

median_entries_per_rid

the median number of prices per rid in this window

QU_3rd

75% of the id's have less than this many prices in the window

window_id

identifier for the window

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
GEKS(times = turvey$month,
price = turvey$price,
id = turvey$commodity,
window_length = 5,
weight = turvey$price * turvey$quantity,
splice_pos = "mean",
num_cores = NULL)

GEKS(times = turvey$month,
price = turvey$price,
id = turvey$commodity,
window_length = 5,
weight = turvey$price * turvey$quantity,
splice_pos = "mean",
num_cores = 2)

MjStansfi/GEKS_package documentation built on May 12, 2021, 8:44 p.m.