Learn R Programming

FoReco (version 0.2.4)

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

Description

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

Usage

FoReco2ts(recf, ...)

Arguments

recf

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

...

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

Value

A list of class "ts" objects

See Also

Other utilities: Cmatrix(), commat(), ctf_tools(), hts_tools(), lcmat(), oct_bounds(), score_index(), shrink_estim(), thf_tools()

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