rtModel {hpiR} | R Documentation |
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, 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
# 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'))
[Package hpiR version 0.3.2 Index]