FoReco_data | R Documentation |
A two-level hierarchy with \mjseqnn = 8 monthly time series. In the cross-sectional framework,
at any time it is \mjseqnTot = A + B + C, \mjseqnA = AA + AB and \mjseqnB = BA + BB
(the bottom time series being \mjseqnAA, \mjseqnAB, \mjseqnBA, \mjseqnBB, and \mjseqnC, it is \mjseqnn_b = 5).
The monthly observations are aggregated to their annual (\mjseqnk = 12),
semi-annual (\mjseqnk = 6), four-monthly (\mjseqnk = 4), quarterly (\mjseqnk = 3), and
bi-monthly (\mjseqnk = 2) counterparts. The monthly bottom time series are simulated
from five different SARIMA models (see
Using the `FoReco` package
).
There are 180 (15 years) monthly observations: the first 168 values (14 years) are used as
training set, and the last 12 form the test set.
data(FoReco_data)
An object of class "list"
:
(\mjseqn8 \times 28) matrix of base forecasts. Each row identifies a time series and the forecasts are ordered as [lowest_freq' ... highest_freq']'.
(\mjseqn8 \times 28) matrix of test set. Each row identifies a time series and the observed values are ordered as [lowest_freq' ... highest_freq']'.
(\mjseqn8 \times 392) matrix of in-sample residuals. Each row identifies a time series and the in-sample residuals are ordered as [lowest_freq' ... highest_freq']'.
(\mjseqn3 \times 5) cross-sectional (contemporaneous) aggregation matrix.
List of the observations at any levels and temporal frequencies.
data(FoReco_data)
# Cross-sectional reconciliation for all temporal aggregation levels
# (annual, ..., bi-monthly, monthly)
K <- c(12, 6, 4, 3, 2, 1)
mbase <- FoReco2matrix(FoReco_data$base, m = 12)
mres <- FoReco2matrix(FoReco_data$res, m = 12)
hts_recf <- lapply(K, function(k){
htsrec(mbase[[paste0("k", k)]], C = FoReco_data$C, comb = "shr",
res = mres[[paste0("k", k)]], keep = "recf")
})
names(hts_recf) <- paste("k", K, sep="")
# Forecast reconciliation through temporal hierarchies for all time series
# comb = "acov"
n <- NROW(FoReco_data$base)
thf_recf <- matrix(NA, n, NCOL(FoReco_data$base))
dimnames(thf_recf) <- dimnames(FoReco_data$base)
for(i in 1:n){
# ts base forecasts ([lowest_freq' ... highest_freq']')
tsbase <- FoReco_data$base[i, ]
# ts residuals ([lowest_freq' ... highest_freq']')
tsres <- FoReco_data$res[i, ]
thf_recf[i,] <- thfrec(tsbase, m = 12, comb = "acov",
res = tsres, keep = "recf")
}
# Iterative cross-temporal reconciliation
# Each iteration: t-acov + cs-shr
ite_recf <- iterec(FoReco_data$base, note=FALSE,
m = 12, C = FoReco_data$C,
thf_comb = "acov", hts_comb = "shr",
res = FoReco_data$res, start_rec = "thf")$recf
# Heuristic first-cross-sectional-then-temporal cross-temporal reconciliation
# cs-shr + t-acov
cst_recf <- cstrec(FoReco_data$base, m = 12, C = FoReco_data$C,
thf_comb = "acov", hts_comb = "shr",
res = FoReco_data$res)$recf
# Heuristic first-temporal-then-cross-sectional cross-temporal reconciliation
# t-acov + cs-shr
tcs_recf <- tcsrec(FoReco_data$base, m = 12, C = FoReco_data$C,
thf_comb = "acov", hts_comb = "shr",
res = FoReco_data$res)$recf
# Optimal cross-temporal reconciliation
# comb = "bdshr"
oct_recf <- octrec(FoReco_data$base, m = 12, C = FoReco_data$C,
comb = "bdshr", res = FoReco_data$res, keep = "recf")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.