FoReco (version 0.1.1)

score_index: Measuring forecasting accuracy

Description

Function to calculate the accuracy indices of the reconciled point forecasts of a cross-temporal (not only, see examples) system (more in Average relative accuracy indices).

Usage

score_index(recf, base, test, m, nb, type = "mse", compact = TRUE)

Arguments

recf

list of q (forecast origins) reconciled forecasts' matrices ([n x h(k* + m)] in the cross-temporal, [h x n] in cross-sectional and vectors of length [h(k* + m)] in temporal framework).

base

list of q (forecast origins) base forecasts' matrices ([n x h(k* + m)] in the cross-temporal, [n x h] in cross-sectional and [h(k* + m) x 1] in temporal framework).

test

list of q (forecast origins) test observations' matrices ([n x h(k* + m)] in the cross-temporal, [n x h] in cross-sectional and [h(k* + m) x 1] in temporal framework).

m

highest frequency of the forecasted time series.

nb

number of bottom time series in the cross-sectional framework.

type

type of accuracy measure ("mse" Mean Square Error, "rmse" Root Mean Square Error or "mae" Mean Absolute Error)

compact

if TRUE return only the summary matrix.

Value

It returns a summary table called Avg_mat (if compact option is TRUE, default), otherwise it returns a list of four tables (more in Average relative accuracy indices).

References

Di Fonzo, T., Girolimetto, D. (2020), Cross-Temporal Forecast Reconciliation: Optimal Combination Method and Heuristic Alternatives, Department of Statistical Sciences, University of Padua, arXiv:2006.08570.

Examples

Run this code
# NOT RUN {
data(FoReco_data)

# Cross-temporal framework
oct_recf <- octrec(FoReco_data$base, m = 12, C = FoReco_data$C,
                   comb = "bdshr", res = FoReco_data$res)$recf
oct_score <- score_index(recf = oct_recf,
                         base = FoReco_data$base,
                         test = FoReco_data$test, m = 12, nb = 5)

# Cross-sectional framework
# monthly base forecasts
id <- which(simplify2array(strsplit(colnames(FoReco_data$base), split = "_"))[1, ] == "k1")
mbase <- t(FoReco_data$base[, id])
# monthly test set
mtest <- t(FoReco_data$test[, id])
# monthly residuals
id <- which(simplify2array(strsplit(colnames(FoReco_data$res), split = "_"))[1, ] == "k1")
mres <- t(FoReco_data$res[, id])
# monthly reconciled forecasts
mrecf <- htsrec(mbase, C = FoReco_data$C, comb = "shr", res = mres)$recf
# score
hts_score <- score_index(recf = mrecf, base = mbase, test = mtest, nb = 5)

# Temporal framework
data(FoReco_data)
# top ts base forecasts ([lowest_freq' ...  highest_freq']')
topbase <- FoReco_data$base[1, ]
# top ts residuals ([lowest_freq' ...  highest_freq']')
topres <- FoReco_data$res[1, ]
# top ts test ([lowest_freq' ...  highest_freq']')
toptest <- FoReco_data$test[1, ]
# top ts recf ([lowest_freq' ...  highest_freq']')
toprecf <- thfrec(topbase, m = 12, comb = "acov", res = topres)$recf
# score
thf_score <- score_index(recf = toprecf, base = topbase, test = toptest, m = 12)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab