Skip to contents

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.

Usage

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

Arguments

base

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

agg_mat

A (\(n_a \times n_b\)) numeric matrix representing the cross-sectional aggregation matrix. It maps the \(n_b\) bottom-level (free) variables into the \(n_a\) upper (constrained) variables.

cons_mat

A (\(n_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 \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 osqp for projection approach.

  • "strc_osqp": Numerical solution using osqp for structural approach.

nn

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

  • "osqp": quadratic programming optimization (osqp solver).

  • "sntz": heuristic "set-negative-to-zero" (Di Fonzo and Girolimetto, 2023).

settings

An object of class osqpSettings specifying settings for the osqp solver. For details, refer to the osqp documentation (Stellato et al., 2020).

bounds

A (\(n \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).

Value

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

References

Byron, R.P. (1978), The estimation of large social account matrices, Journal of the Royal Statistical Society, Series A, 141, 3, 359-367. 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. doi:10.2307/2982515

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. (2023), Point and probabilistic forecast reconciliation for general linearly constrained multiple time series, Statistical Methods & Applications, in press. 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. 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. 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. 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. 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. 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()

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
#>     obj_val   run_time iter    pri_res status status_polish
#> 1 -352.4619 2.6374e-05   25 1.7763e-15      1             1