View source: R/calcKFoldError.R
| calcKFoldError | R Documentation | 
Use a KFold (out of sample) approach to estimate index accuracy
calcKFoldError(hpi_obj, pred_df, k = 10, seed = 1, smooth = FALSE, ...)
| 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 | 
object of class 'hpiaccuracy' inheriting from class 'data.frame' containing the following fields:
Unique Pair ID
Transaction Price
Predicted price
(Prediction - Actual) / Actual
log(prediction) - log(actual)
Period of the prediction
 # 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.