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

View source: R/FoReco2ts.R

FoReco2tsR Documentation

Reconciled forecasts matrix/vector to time-series class

Description

\loadmathjax

Function to transform the matrix/vector of FoReco forecasts input and output into a list of time series/matrix/vector objects.

Usage

FoReco2ts(recf, m, ...)

FoReco2matrix(recf, m)

Arguments

recf

(\mjseqnh(k^\ast + m) \times 1) forecasts vector from thfrec, (\mjseqnh \times n) forecasts matrix from htsrec or (\mjseqnn \times h(k^\ast + m)) forecasts matrix from octrec, tcsrec, cstrec, iterec, ctbu.

m

Highest available sampling frequency per seasonal cycle (max. order of temporal aggregation, \mjseqnm), or a subset of \mjseqnp factors of \mjseqnm.

...

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

Value

A list of class "ts" objects for FoReco2ts and a list of matrix/vector for FoReco2matrix

See Also

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

Examples

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
ts_oct <- FoReco2ts(recf = oct_recf, m = 12, start = c(15, 1))
mat_oct <- FoReco2matrix(recf = oct_recf, m = 12)

# Cross-sectional framework
# monthly base forecasts
mbase <- FoReco2matrix(FoReco_data$base, m = 12)$k1
# monthly residuals
mres <- FoReco2matrix(FoReco_data$res, m = 12)$k1
hts_recf <- htsrec(mbase, C = FoReco_data$C, comb = "shr", res = mres)$recf
ts_hts <- FoReco2ts(recf = hts_recf, start = c(15, 1), frequency = 12)
mat_hts <- FoReco2matrix(recf = hts_recf)

# 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
ts_thf <- FoReco2ts(recf = thf_recf, m = 12, start = c(15, 1))
mat_thf <- FoReco2matrix(recf = thf_recf, m = 12)


FoReco documentation built on May 31, 2023, 5:17 p.m.