csmtc {FoCo2} | R Documentation |
Cross-sectional optimal multi-task forecast combination
Description
This function computes the optimal multi-task linear forecast combination, as described in Girolimetto and Di Fonzo (2024)
Usage
csmtc(base, comb = "ols", res = NULL, approach = "proj",
nn = NULL, settings = NULL, bounds = NULL, agg_mat = NULL, ...)
Arguments
base |
A list of |
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
|
agg_mat |
A ( |
... |
Arguments passed on to cscov. |
Value
A (h \times n
) numeric matrix of cross-sectional multi-task combined forecasts.
References
Girolimetto, D. and Di Fonzo, T. (2024), Coherent forecast combination for linearly constrained multiple time series, doi:10.48550/arXiv.2412.03429.
See Also
Other Optimal combination:
cscov()
,
csocc()
,
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 = "shr", res = erc)
yc <- csmtc(base = brc, agg_mat = A, comb = "shr", res = erc)
M <- occmat(base = brc, agg_mat = A, comb = "shr", p = 2, res = erc)$M
M%*%t(yc)-t(rrc)
## UNBALANCED PANEL OF FORECASTS
base2[, 2] <- res2[, 2] <- NA
# Base forecasts' and residuals' lists
bgc <- list(base1, base2)
egc <- list(res1, res2)
matNA <- matrix(1, 3, 2)
matNA[2,2] <- 0
# Aggregation matrix for Z = X + Y
A <- t(c(1,1))
rgc <- csocc(base = bgc, agg_mat = A, comb = "shr", res = egc)
yc <- csmtc(base = bgc, agg_mat = A, comb = "shr", res = egc)
M <- occmat(base = bgc, agg_mat = A, comb = "shr", p = 2, res = egc, matNA = matNA)$M
M%*%t(yc)-t(rgc)