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)
Run the code above in your browser using DataLab