cscov function

Cross-sectional covariance matrix approximation

Cross-sectional covariance matrix approximation

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).

cscov(comb = "ols", n = NULL, agg_mat = NULL, res, mse = TRUE, shrink_fun = shrink_estim, ...)

Arguments

  • comb: A string specifying the reconciliation method.

    • Ordinary least squares:

      • "ols" (default) - identity error covariance matrix.
    • Weighted least squares:

      • "str" - structural variances.
      • "wls" - series variances (uses res).
    • Generalized least squares:

      • "shr"/"sam" - shrunk/sample covariance (uses res).
  • n: Number of variables (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.

  • res: An (N×nN \times 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×nn \times n) symmetric positive (semi-)definite matrix.

Examples

# Aggregation matrix for Z = X + Y A <- 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 methods cov2 <- cscov("str", agg_mat = A) # STR methods cov3 <- cscov("wls", res = res) # WLS methods cov4 <- cscov("shr", res = res) # SHR methods cov5 <- cscov("sam", res = res) # SAM methods # Custom covariance matrix cscov.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")

See Also

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