hpiR (version 0.2.0)

calcKFoldError: Calculate index error with FKold (out of sample)

Description

Use a KFold (out of sample) approach to estimate index accuracy

Usage

calcKFoldError(hpi_obj, pred_df, k = 10, seed = 1, smooth = FALSE, ...)

Arguments

hpi_obj

HPI object of class 'hpi'

pred_df

Data.frame of sales to be used for assessing predictive quality of index

k

default=10; Number of folds to apply to holdout process

seed

default=1; Random seed generator to control the folding process

smooth

default = FALSE; Calculate on the smoothed index

...

Additional Arguments

Value

object of class `hpiaccuracy` inheriting from class `data.frame` containing the following fields:

prop_id

Property Identification number

pred_price

Predicted price

pred_error

(Prediction - Actual) / Actual

pred_period

Period of the prediction

Examples

Run this code
# NOT RUN {
 # Load data
 data(ex_sales)

 # Create index with raw transaction data
 rt_index <- rtIndex(trans_df = ex_sales,
                     periodicity = 'monthly',
                     min_date = '2010-06-01',
                     max_date = '2015-11-30',
                     adj_type = 'clip',
                     date = 'sale_date',
                     price = 'sale_price',
                     trans_id = 'sale_id',
                     prop_id = 'pinx',
                     estimator = 'robust',
                     log_dep = TRUE,
                     trim_model = TRUE,
                     max_period = 48,
                     smooth = FALSE)

  # Create prediction data
  rt_data <- rtCreateTrans(trans_df = ex_sales,
                          prop_id = 'pinx',
                          trans_id = 'sale_id',
                          price = 'sale_price',
                          periodicity = 'monthly',
                          date = 'sale_date')

  # Calc Accuracy
  kf_accr <- calcKFoldError(hpi_obj = rt_index,
                            pred_df = rt_data,
                            k = 10,
                            seed = 123,
                            smooth = FALSE)

# }

Run the code above in your browser using DataLab