calcForecastError: Calculate the forecast accuracy of series of indexes

Description Usage Arguments Value Further Details Examples

View source: R/calcForecastError.R

Description

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

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 # 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)

hpiR documentation built on April 1, 2020, 5:09 p.m.