csocc {FoCo2} | R Documentation |
Cross-sectional optimal coherent forecast combination
Description
This function implements the optimal linear coherent forecast combination for a linearly constrained (e.g., hierarchical/grouped) multiple time series combining forecasts from multiple sources (experts). The method minimizes forecast errors while ensuring that the resulting forecasts are coherent, meaning they satisfy the constraints across the time series. Using a linear constrained optimization approach, csocc combines forecasts from multiple experts, accounting for the relations between variables and constraints. In addition, linear inequality constraints (e.g. non-negative forecasts) can be imposed, if needed.
Usage
csocc(base, agg_mat, cons_mat, comb = "ols", res = NULL,
approach = "proj", nn = NULL, settings = NULL, bounds = NULL, ...)
Arguments
base |
A list of |
agg_mat |
A ( |
cons_mat |
A ( |
comb |
A string specifying the reconciliation method. For details, see cscov. |
res |
A list of |
approach |
A string specifying the approach used to compute the reconciled forecasts. Options include:
|
nn |
A string specifying the algorithm to compute non-negative forecasts:
|
settings |
An object of class |
bounds |
A matrix (see
|
... |
Arguments passed on to cscov. |
Details
If an expert does not provide a forecast for a given variable,
the missing value can be represented as NA
.
For instance, consider a case where the number of experts is
p = 4
, with n = 3
variables and h = 2
. If the
second and third experts do not provide forecasts for, respectively, the second and first variable,
the corresponding matrix in the base list will be as follows:
\texttt{base[[1]]} = \begin{bmatrix} \hat{y}_{1,1}^{1} & \hat{y}_{2,1}^{1} & \hat{y}_{3,1}^{1} \\
\hat{y}_{1,2}^{1} & \hat{y}_{2,2}^{1} & \hat{y}_{3,2}^{1} \end{bmatrix}, \quad
\texttt{base[[2]]} = \begin{bmatrix} \hat{y}_{1,1}^{2} & \texttt{NA} & \hat{y}_{3,1}^{2} \\
\hat{y}_{1,2}^{2} & \texttt{NA} & \hat{y}_{3,2}^{2} \end{bmatrix},
\texttt{base[[3]]} = \begin{bmatrix} \texttt{NA} & \hat{y}_{2,1}^{3} & \hat{y}_{3,1}^{3} \\
\texttt{NA} & \hat{y}_{2,2}^{3} & \hat{y}_{3,2}^{3} \end{bmatrix}, \quad
\texttt{base[[4]]} = \begin{bmatrix} \hat{y}_{1,1}^{4} & \hat{y}_{2,1}^{4} & \hat{y}_{3,1}^{4} \\
\hat{y}_{1,2}^{4} & \hat{y}_{2,2}^{4} & \hat{y}_{3,2}^{4} \end{bmatrix}.
Value
A (h \times n
) numeric matrix of cross-sectional combined and reconciled forecasts.
References
Di Fonzo, T. and Girolimetto, D. (2023), Spatio-temporal reconciliation of solar forecasts, Solar Energy, 251, 13–29. doi:10.1016/j.solener.2023.01.003
Girolimetto, D. and Di Fonzo, T. (2024), Coherent forecast combination for linearly constrained multiple time series, doi:10.48550/arXiv.2412.03429.
Stellato, B., Banjac, G., Goulart, P., Bemporad, A. and Boyd, S. (2020), OSQP: An Operator Splitting solver for Quadratic Programs, Mathematical Programming Computation, 12, 4, 637-672. doi:10.1007/s12532-020-00179-2
See Also
Other Optimal combination:
cscov()
,
csmtc()
,
occmat()
Examples
set.seed(123)
# (2 x 3) base forecasts matrix (simulated), expert 1
base1 <- matrix(rnorm(6, mean = c(20, 10, 10)), 2, byrow = TRUE)
# (10 x 3) in-sample residuals matrix (simulated), expert 1
res1 <- t(matrix(rnorm(n = 30), nrow = 3))
# (2 x 3) base forecasts matrix (simulated), expert 2
base2 <- matrix(rnorm(6, mean = c(20, 10, 10)), 2, byrow = TRUE)
# (10 x 3) in-sample residuals matrix (simulated), expert 2
res2 <- t(matrix(rnorm(n = 30), nrow = 3))
## BALANCED PANEL OF FORECASTS
# Base forecasts' and residuals' lists
brc <- list(base1, base2)
erc <- list(res1, res2)
# Aggregation matrix for Z = X + Y
A <- t(c(1,1))
rrc <- csocc(base = brc, agg_mat = A, comb = "wls", res = erc)
# Zero constraints matrix for Z - X - Y = 0
C <- t(c(1, -1, -1))
rrc <- csocc(base = brc, cons_mat = C, comb = "wls", res = erc) # same results
## UNBALANCED PANEL OF FORECASTS
base2[, 2] <- res2[, 2] <- NA
# Base forecasts' and residuals' lists
bgc <- list(base1, base2)
egc <- list(res1, res2)
# Aggregation matrix for Z = X + Y
A <- t(c(1,1))
rgc <- csocc(base = bgc, agg_mat = A, comb = "shrbe", res = egc)