rtModel: Estimate repeat transaction model for index creation

Description Usage Arguments Value Further Details Examples

View source: R/rtModel.R

Description

Estimate coefficients for an index via the repeat transaction approach (generic method)

Usage

1
2
rtModel(rt_df, time_matrix, price_diff, estimator, lm_recover = TRUE,
  ...)

Arguments

rt_df

Repeat transactions dataset from rtCreateTrans()

time_matrix

Time matrix object from rtTimeMatrix()

price_diff

Difference in price between the two transactions

estimator

Type of model to estimates (base, robust, weighted). Must be in that class.

lm_recover

(TRUE) Allows robust model to use linear model if it fails

...

Additional arguments

Value

'rtmodel' object

Further Details

Three available specific methods: 'base', 'robust' and 'weighted'

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
  # Load data
  data(ex_sales)

  # With a raw transaction data.frame
  rt_data <- rtCreateTrans(trans_df = ex_sales,
                           prop_id = 'pinx',
                           trans_id = 'sale_id',
                           price = 'sale_price',
                           periodicity = 'monthly',
                           date = 'sale_date')

  # Calc price differences
  price_diff <- rt_data$price_2 - rt_data$price_1

  # Create time matrix
  rt_matrix <- rtTimeMatrix(rt_data)

  # Calculate model
  rt_model <- rtModel(rt_df = rt_data,
                      price_diff = price_diff,
                      time_matrix = rt_matrix,
                      estimator = structure('base', class='base'))

hpiR documentation built on April 1, 2020, 5:09 p.m.