This function provides an approximation of the cross-temporal base forecasts errors covariance matrix using different reconciliation methods (Di Fonzo and Girolimetto, 2023, Girolimetto et al., 2023).
ctcov(comb ="ols", n =NULL, agg_mat =NULL, agg_order =NULL, res =NULL, tew ="sum", mse =TRUE, shrink_fun = shrink_estim,...)
Arguments
comb: A string specifying the reconciliation method.
"hbshr"/"hbsam" - shrunk/sample high frequency bottom time series covariance.
"bshr"/"bsam" - shrunk/sample bottom time series covariance.
"hshr"/"hsam" - shrunk/sample high frequency covariance.
n: Cross-sectional number of variables.
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.
agg_order: Highest available sampling frequency per seasonal cycle (max. order of temporal aggregation, m), or a vector representing a subset of p factors of m.
res: A (n×N(k∗+m)) optional numeric matrix containing the in-sample residuals at all the temporal frequencies ordered from the lowest frequency to the highest frequency (columns) for each variable (rows). This matrix is used to compute some covariance matrices.
tew: A string specifying the type of temporal aggregation. Options include: "sum" (simple summation, default), "avg" (average), "first" (first value of the period), and "last" (last value of the period).
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(k∗+m)×n(k∗+m)) symmetric matrix.
Examples
set.seed(123)# Aggregation matrix for Z = X + YA <- t(c(1,1))# (3 x 70) in-sample residuals matrix (simulated),# agg_order = 4 (annual-quarterly)res <- rbind(rnorm(70), rnorm(70), rnorm(70))cov1 <- ctcov("ols", n =3, agg_order =4)# OLS methodscov2 <- ctcov("str", agg_mat = A, agg_order =4)# STR methodscov3 <- ctcov("csstr", agg_mat = A, agg_order =4)# CSSTR methodscov4 <- ctcov("testr", n =3, agg_order =4)# TESTR methodscov5 <- ctcov("wlsv", agg_order =4, res = res)# WLSv methodscov6 <- ctcov("wlsh", agg_order =4, res = res)# WLSh methodscov7 <- ctcov("shr", agg_order =4, res = res)# SHR methodscov8 <- ctcov("sam", agg_order =4, res = res)# SAM methodscov9 <- ctcov("acov", agg_order =4, res = res)# ACOV methodscov10 <- ctcov("Sshr", agg_order =4, res = res)# Sshr methodscov11 <- ctcov("Ssam", agg_order =4, res = res)# Ssam methodscov12 <- ctcov("hshr", agg_order =4, res = res)# Hshr methodscov13 <- ctcov("hsam", agg_order =4, res = res)# Hsam methodscov14 <- ctcov("hbshr", agg_mat = A, agg_order =4, res = res)# HBshr methodscov15 <- ctcov("hbsam", agg_mat = A, agg_order =4, res = res)# HBsam methodscov16 <- ctcov("bshr", agg_mat = A, agg_order =4, res = res)# Bshr methodscov17 <- ctcov("bsam", agg_mat = A, agg_order =4, res = res)# Bsam methodscov18 <- ctcov("bdshr", agg_order =4, res = res)# BDshr methodscov19 <- ctcov("bdsam", agg_order =4, res = res)# BDsam methods# Custom covariance matrixctcov.ols2 <-function(comb, x) diag(x)cov20 <- ctcov(comb ="ols2", x =21)# == ctcov("ols", n = 3, agg_order = 4)
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")
Girolimetto, D., Athanasopoulos, G., Di Fonzo, T. and Hyndman, R.J. (2024), Cross-temporal probabilistic forecast reconciliation: Methodological and practical issues. International Journal of Forecasting, 40, 3, 1134-1151. tools:::Rd_expr_doi("10.1016/j.ijforecast.2023.10.003")