This function provides an approximation of the cross-sectional base forecasts errors covariance matrix using different reconciliation methods (see Wickramasuriya et al., 2019 and Di Fonzo and Girolimetto, 2023).
agg_mat: A (na×nb) numeric matrix representing the cross-sectional aggregation matrix. It maps the nb bottom-level (free) variables into the na upper (constrained) variables.
res: An (N×n) optional numeric matrix containing the in-sample residuals. This matrix is used to compute some covariance matrices.
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).
...: Not used.
Returns
A (n×n) symmetric positive (semi-)definite matrix.
Examples
# Aggregation matrix for Z = X + YA <- t(c(1,1))# (10 x 3) in-sample residuals matrix (simulated)res <- t(matrix(rnorm(n =30), nrow =3))cov1 <- cscov("ols", n =3)# OLS methodscov2 <- cscov("str", agg_mat = A)# STR methodscov3 <- cscov("wls", res = res)# WLS methodscov4 <- cscov("shr", res = res)# SHR methodscov5 <- cscov("sam", res = res)# SAM methods# Custom covariance matrixcscov.ols2 <-function(comb, x) diag(x)cscov(comb ="ols2", x =3)# == cscov("ols", n = 3)
References
Di Fonzo, T. and Girolimetto, D. (2023), Cross-temporal forecast reconciliation: Optimal combination method and heuristic alternatives, International Journal of Forecasting, 39, 1, 39-57. tools:::Rd_expr_doi("10.1016/j.ijforecast.2021.08.004")
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")