calcForecastError: Calculate the forecast accuracy of series of indexes

View source: R/calcForecastError.R

calcForecastErrorR Documentation

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

price

Transaction Price

pred_price

Predicted price

error

(Prediction - Actual) / Actual

log_error

log(prediction) - log(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


 # Load example sales
 data(ex_sales)

 # Create Index
 hed_index <- hedIndex(trans_df = ex_sales,
                       periodicity = 'monthly',
                       max_date = '2011-12-31',
                       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 = 24,
                       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',
                          max_date = '2011-12-31',
                          trans_id = 'sale_id',
                          price = 'sale_price',
                          periodicity = 'monthly',
                          date = 'sale_date',
                          min_period_dist = 12)


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


andykrause/hpiR documentation built on Feb. 2, 2024, 8:13 p.m.