The cross-temporal forecast reconciliation procedure by
Kourentzes and Athanasopoulos (2019) can be viewed as an ensemble forecasting
procedure which exploits the simple averaging of different forecasts.
First, for each time series the forecasts at any temporal aggregation order are
reconciled using temporal hierarchies (thfrec
), then
time-by-time cross-sectional reconciliation is performed (htsrec
).
The projection matrices obtained at this step are then averaged and used to
cross-sectionally reconcile the forecasts obtained at step 1, by this way
fulfilling both cross-sectional and temporal constraints.
tcsrec(basef, m, C, thf_comb, hts_comb, Ut, nb, res, W, Omega,
mse = TRUE, corpcor = FALSE, avg="KA", nn= FALSE,
settings = osqpSettings(verbose = FALSE, eps_abs = 1e-5,
eps_rel = 1e-5, polish_refine_iter = 100, polish = TRUE))
(n x h(k* + m)
) matrix of base forecasts to be reconciled;
n
is the total number of variables, m
is the highest frequency,
k*
is the sum of (p-1
) factors of m
, excluding m
,
and h
is the forecast horizon. Each row identifies, a time series, and the forecasts
are ordered as [lowest_freq' ... highest_freq']'.
Highest available sampling frequency per seasonal cycle (max. order of temporal aggregation).
(na x nb
) cross-sectional (contemporaneous) matrix mapping the bottom
level series into the higher level ones.
Type of the ((k* + m) x (k* + m)
) covariance matrix to be used in
the temporal reconciliation, see more in comb
param of thfrec
.
Type of the (n x n
) covariance matrix to be used in the
cross-sectional reconciliation, see more in comb
param of htsrec
.
Zero constraints cross-sectional (contemporaneous) kernel matrix
\(\textbf{U}'\textbf{Y} = \mathbf{0}\) spanning the null space valid for the reconciled
forecasts. It can be used instead of parameter C
, but needs nb
(n = na + nb). If
the hierarchy admits a structural representation, Ut
has dimension (na x n
).
Number of bottom time series; if C
is present, nb
is not used.
(n x N(k* + m)
) matrix containing the residuals at all the
temporal frequencies ordered [lowest_freq' ... highest_freq']' (columns) for
each variable (row), needed to estimate the covariance matrix when hts_comb =
{"wls",
"shr",
"sam"}
and/or hts_comb =
{"wlsv",
"wlsh",
"acov",
"strar1",
"sar1",
"har1",
"shr",
"sam"}
. The row must be in the same order as basef
.
This option permits to directly enter the covariance matrix in the
cross-sectional reconciliation, see more in W
param of htsrec
.
This option permits to directly enter the covariance matrix in the
reconciliation through temporal hierarchies, see more in Omega
param of thfrec
.
Logical value: TRUE
(default) calculates the
covariance matrix of the in-sample residuals (when necessary) according to the original
hts and thief formulation: no mean correction, T as denominator.
Logical value: TRUE
if corpcor (Sch<U+00E4>fer et
al., 2017) must be used to shrink the sample covariance matrix according to
Sch<U+00E4>fer and Strimmer (2005), otherwise the function uses the same
implementation as package hts.
If avg = "KA"
(default), the final projection matrix M
is the one proposed
by Kourentzes and Athanasopoulos (2019), otherwise it is calculated as simple average of
all the involved projection matrices at step 2 of th procedure (see Di Fonzo and
Girolimetto, 2020).
Logical value, TRUE
if non-negative reconciled forecasts are wished. Warning,
the two-step heuristic reconciliation allows non negativity constraints only in the first step.
This means that non-negativity is not guaranteed in the final reconciled values.
Settings for osqp (object osqpSettings
). The default options
are: verbose = FALSE
, eps_abs = 1e-5
, eps_rel = 1e-5
,
polish_refine_iter = 100
and polish = TRUE
. For details, see the
osqp documentation (Stellato et al., 2019).
The function returns a list with two elements:
recf
(n x h(k* + m)
) reconciled forecasts matrix.
M
Projection matrix (projection approach).
This function performs a two-step cross-temporal forecast reconciliation using
the covariance matrices chosen by the user. If the combinations used by Kourentzes and Athanasopoulos (2019) are
wished, thf_comb
must be set equal to either "struc"
or "wlsv"
,
and hts_comb
equal to either "shr"
or "wls"
.
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.
Kourentzes, N., Athanasopoulos, G. (2019), Cross-temporal coherent forecasts for Australian tourism, Annals of Tourism Research, 75, 393-409.
Sch<U+00E4>fer, J.L., Opgen-Rhein, R., Zuber, V., Ahdesmaki, M., Duarte Silva, A.P., Strimmer, K. (2017), Package `corpcor', R package version 1.6.9 (April 1, 2017), https://CRAN.R-project.org/package= corpcor.
Sch<U+00E4>fer, J.L., Strimmer, K. (2005), A Shrinkage Approach to Large-Scale Covariance Matrix Estimation and Implications for Functional Genomics, Statistical Applications in Genetics and Molecular Biology, 4, 1.
Stellato, B., Banjac, G., Goulart, P., Bemporad, A., Boyd, S. (2018). OSQP: An Operator Splitting Solver for Quadratic Programs, arXiv:1711.08013.
Stellato, B., Banjac, G., Goulart, P., Boyd, S., Anderson, E. (2019), OSQP: Quadratic Programming Solver using the 'OSQP' Library, R package version 0.6.0.3 (October 10, 2019), https://CRAN.R-project.org/package=osqp.
# NOT RUN {
data(FoReco_data)
obj <- tcsrec(FoReco_data$base, m = 12, C = FoReco_data$C, thf_comb = "acov",
hts_comb = "shr", res = FoReco_data$res)
# }
Run the code above in your browser using DataLab