| as_ctmatrix | R Documentation |
These functions convert matrix between the two canonical layouts used in
cross-temporal reconciliation.
Let m be the maximum temporal aggregation order and k^\ast the sum
of a subset of the (p-1) proper factors of m (excluding m);
let h be the forecast horizon for the lowest frequency series (e.g.,
most aggregated temporal forecast horizon) and n the number of variables:
Horizon-stacked layout (cross-temporal version): a
h \times n(k^\ast + m) matrix where rows are the most aggregated temporal
forecast horizons, and the values in each row are ordered from the lowest frequency
(most temporally aggregated) to the highest frequency grouped by variable.
Cross-temporal layout: a n \times h(k^\ast + m) matrix where
rows are variables, and horizons for each temporal block appear consecutively.
rows are variables, and the values in each row are ordered from the lowest frequency
(most temporally aggregated) to the highest frequency.
Then, as_ctmatrix converts a (h \times n(k^\ast+m))
horizon-stacked to a (n \times h(k^\ast+m)) cross-temporal matrix;
as_hstack_ctlayout performs the inverse transform.
as_ctmatrix(hmat, agg_order, n, row_names = NULL)
as_hstack_ctlayout(ctmat, agg_order)
hmat |
A |
agg_order |
Highest available sampling frequency per seasonal cycle
(max. order of temporal aggregation, |
n |
Cross-sectional number of variables. |
row_names |
Optional character vector of length |
ctmat |
A |
as_ctmatrix returns a n \times h(k^\ast+m) numeric
matrix in cross-temporal layout.
as_hstack_ctlayout returns a h \times n(k^\ast+m) numeric
matrix in horizon-stacked layout (cross-temporal version).
Utilities:
FoReco2matrix(),
aggts(),
as_tevector(),
balance_hierarchy(),
commat(),
csprojmat(),
cstools(),
ctprojmat(),
cttools(),
df2aggmat(),
lcmat(),
recoinfo(),
res2matrix(),
set_bounds(),
shrink_estim(),
shrink_oasd(),
teprojmat(),
tetools(),
unbalance_hierarchy()
h <- 2 # horizons
n <- 3 # variables
m <- 4 # temporal aggregation order
kt <- tetools(m)$dim["kt"]
# Build a horizon-stacked matrix: h rows, n * k_t columns
input_ct <- matrix(seq_len(h * n * kt), nrow = n, byrow = TRUE)
hmat <- as_hstack_ctlayout(input_ct, agg_order = m)
ctmat <- as_ctmatrix(hmat, agg_order = m, n = n)
# all.equal(ctmat, input_ct, check.attributes = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.