csrec function

Optimal combination cross-sectional reconciliation

Optimal combination cross-sectional reconciliation

This function performs optimal (in least squares sense) combination cross-sectional forecast reconciliation for a linearly constrained (e.g., hierarchical/grouped) multiple time series (Wickramasuriya et al., 2019, Panagiotelis et al., 2022, Girolimetto and Di Fonzo, 2023). The reconciled forecasts are calculated using either a projection approach (Byron, 1978, 1979) or the equivalent structural approach by Hyndman et al. (2011). Non-negative (Di Fonzo and Girolimetto, 2023) and immutable (including Zhang et al., 2023) reconciled forecasts can be considered.

csrec(base, agg_mat, cons_mat, comb = "ols", res = NULL, approach = "proj", nn = NULL, settings = NULL, bounds = NULL, immutable = NULL, ...)

Arguments

  • base: A (h×nh \times n) numeric matrix or multivariate time series (mts class) containing the base forecasts to be reconciled; hh is the forecast horizon, and nn is the total number of time series (n=na+nbn = n_a + n_b).

  • agg_mat: A (na×nbn_a \times n_b) numeric matrix representing the cross-sectional aggregation matrix. It maps the nbn_b bottom-level (free) variables into the nan_a upper (constrained) variables.

  • cons_mat: A (na×nn_a \times n) numeric matrix representing the cross-sectional zero constraints. It spans the null space for the reconciled forecasts.

  • comb: A string specifying the reconciliation method. For a complete list, see cscov .

  • res: An (N×nN \times n) optional numeric matrix containing the in-sample residuals. This matrix is used to compute some covariance matrices.

  • approach: A string specifying the approach used to compute the reconciled forecasts. Options include:

    • "proj" (default): Projection approach according to Byron (1978, 1979).

    • "strc": Structural approach as proposed by Hyndman et al. (2011).

    • "proj_osqp": Numerical solution using list("osqp")

      for projection approach.

    • "strc_osqp": Numerical solution using list("osqp")

      for structural approach.

  • nn: A string specifying the algorithm to compute non-negative reconciled forecasts:

    • "osqp": quadratic programming optimization (list("osqp") solver).
    • "sntz": heuristic "set-negative-to-zero" (Di Fonzo and Girolimetto, 2023).
  • settings: An object of class osqpSettings specifying settings for the list("osqp") solver. For details, refer to the c("list("osqp")", " documentation") (Stellato et al., 2020).

  • bounds: A (n×2n \times 2) numeric matrix specifying the cross-sectional bounds. The first column represents the lower bound, and the second column represents the upper bound.

  • immutable: A numeric vector containing the column indices of the base forecasts (base parameter) that should be fixed.

  • ...: Arguments passed on to cscov

    • mse: If TRUE (default) the residuals used to compute the covariance matrix are not mean-corrected.
    • shrink_fun: Shrinkage function of the covariance matrix, shrink_estim (default).

Returns

A (h×nh \times n) numeric matrix of cross-sectional reconciled forecasts.

Examples

set.seed(123) # (2 x 3) base forecasts matrix (simulated), Z = X + Y base <- matrix(rnorm(6, mean = c(20, 10, 10)), 2, byrow = TRUE) # (10 x 3) in-sample residuals matrix (simulated) res <- t(matrix(rnorm(n = 30), nrow = 3)) # Aggregation matrix for Z = X + Y A <- t(c(1,1)) reco <- csrec(base = base, agg_mat = A, comb = "wls", res = res) # Zero constraints matrix for Z - X - Y = 0 C <- t(c(1, -1, -1)) reco <- csrec(base = base, cons_mat = C, comb = "wls", res = res) # same results # Non negative reconciliation base[1,3] <- -base[1,3] # Making negative one of the base forecasts for variable Y nnreco <- csrec(base = base, agg_mat = A, comb = "wls", res = res, nn = "osqp") recoinfo(nnreco, verbose = FALSE)$info

References

Byron, R.P. (1978), The estimation of large social account matrices, Journal of the Royal Statistical Society, Series A, 141, 3, 359-367. tools:::Rd_expr_doi("10.2307/2344807")

Byron, R.P. (1979), Corrigenda: The estimation of large social account matrices, Journal of the Royal Statistical Society, Series A, 142(3), 405. tools:::Rd_expr_doi("10.2307/2982515")

Di Fonzo, T. and Girolimetto, D. (2023), Spatio-temporal reconciliation of solar forecasts, Solar Energy, 251, 13–29. tools:::Rd_expr_doi("10.1016/j.solener.2023.01.003")

Girolimetto, D. and Di Fonzo, T. (2023), Point and probabilistic forecast reconciliation for general linearly constrained multiple time series, Statistical Methods & Applications, in press. tools:::Rd_expr_doi("10.1007/s10260-023-00738-6") .

Hyndman, R.J., Ahmed, R.A., Athanasopoulos, G. and Shang, H.L. (2011), Optimal combination forecasts for hierarchical time series, Computational Statistics & Data Analysis, 55, 9, 2579-2589. tools:::Rd_expr_doi("10.1016/j.csda.2011.03.006")

Panagiotelis, A., Athanasopoulos, G., Gamakumara, P. and Hyndman, R.J. (2021), Forecast reconciliation: A geometric view with new insights on bias correction, International Journal of Forecasting, 37, 1, 343–359. tools:::Rd_expr_doi("10.1016/j.ijforecast.2020.06.004")

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. tools:::Rd_expr_doi("10.1007/s12532-020-00179-2")

Wickramasuriya, S.L., Athanasopoulos, G. and Hyndman, R.J. (2019), Optimal forecast reconciliation for hierarchical and grouped time series through trace minimization, Journal of the American Statistical Association, 114, 526, 804-819. tools:::Rd_expr_doi("10.1080/01621459.2018.1448825")

Zhang, B., Kang, Y., Panagiotelis, A. and Li, F. (2023), Optimal reconciliation with immutable forecasts, European Journal of Operational Research, 308(2), 650–660. tools:::Rd_expr_doi("10.1016/j.ejor.2022.11.035")

See Also

Regression-based reconciliation: ctrec(), terec()

Cross-sectional framework: csboot(), csbu(), cscov(), cslcc(), csmo(), cstd(), cstools()