hpiR (version 0.2.0)

calcForecastError: Calculate the forecast accuracy of series of indexes

Description

Estimate the index accuracy with forecasting for a (progressive) series of indexes

Usage

calcForecastError(is_obj, pred_df, return_forecasts = FALSE,
  forecast_length = 1, ...)

Arguments

is_obj

Object of class 'hpiseries'

pred_df

Set of sales to be used for predictive quality of index

return_forecasts

default = FALSE; return the forecasted indexes

forecast_length

default = 1; Length of period(s) in time to forecast

...

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

series

Series position from which the prediction was generated

Further Details

If you set `return_forecasts` = TRUE, the forecasted indexes for each period will be returned in the `forecasts` attribute of the `hpiaccuracy` object. (attr(accr_obj, 'forecasts')

For now, the `pred_df` object must be a set of repeat transactions with the class `rt`, inheriting from `hpidata`

Examples

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

 # Create Index
 hed_index <- hedIndex(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,
                       dep_var = 'price',
                       ind_var = c('tot_sf', 'beds', 'baths'),
                       smooth = FALSE)

 # Create Series (Suppressing messages do to small sample size of this example)
  suppressMessages(
    hpi_series <- createSeries(hpi_obj = hed_index,
                               train_period = 12))

 # 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')


 # Calculate forecast accuracty
 fc_accr <- calcForecastError(is_obj = hpi_series,
                              pred_df = rt_data)

# }

Run the code above in your browser using DataLab