hpiR (version 0.2.0)

rtModel: Estimate repeat transaction model for index creation

Description

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

Usage

rtModel(rt_df, time_matrix, price_diff, estimator, ...)

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.

...

Additional arguments

Value

`rtmodel` object

Further Details

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

Examples

Run this code
# NOT RUN {
  # 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'))

# }

Run the code above in your browser using DataCamp Workspace