FoReco (version 0.1.1)

FoReco2ts: Reconciled forecasts matrix/vector to time-series class

Description

Function to transform the matrix/vector of reconciled forecasts (recf from htsrec, thfrec, octrec, tcsrec, cstrec, iterec, ctbu) into a list of time series objects.

Usage

FoReco2ts(recf, ...)

Arguments

recf

(h(k* + m) x 1) reconciled forecasts vector from thfrec, (h x n) reconciled forecasts matrix from htsrec or (n x h(k* + m)) reconciled forecasts matrix from octrec, tcsrec, cstrec, iterec, ctbu.

...

optional arguments to ts (i.e. starting date); frequency is only required for the cross-sectional system. .

Value

A list of class "ts" objects

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
obj_oct <- FoReco2ts(recf = oct_recf, start = c(15, 1))

# Cross-sectional framework
# monthly base forecasts
id <- which(simplify2array(strsplit(colnames(FoReco_data$base),
                                    split = "_"))[1, ] == "k1")
mbase <- t(FoReco_data$base[, id])
# monthly residuals
id <- which(simplify2array(strsplit(colnames(FoReco_data$res),
                                    split = "_"))[1, ] == "k1")
mres <- t(FoReco_data$res[, id])
hts_recf <- htsrec(mbase, C = FoReco_data$C, comb = "shr", res = mres)$recf
obj_hts <- FoReco2ts(recf = hts_recf, start = c(15, 1), frequency = 12)

# Temporal framework
# 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, ]
thf_recf <- thfrec(topbase, m = 12, comb = "acov", res = topres)$recf
obj_thf <- FoReco2ts(recf = thf_recf, start = c(15, 1))

# }

Run the code above in your browser using DataLab