Skip to contents

Some useful tools for the cross-temporal forecast reconciliation of a linearly constrained (e.g., hierarchical/grouped) multiple time series.

Usage

cttools(agg_mat, cons_mat, agg_order, tew = "sum", fh = 1, sparse = TRUE)

Arguments

agg_mat

A (\(n_a \times n_b\)) numeric matrix representing the cross-sectional aggregation matrix. It maps the \(n_b\) bottom-level (free) variables into the \(n_a\) upper (constrained) variables.

cons_mat

A (\(n_a \times n\)) numeric matrix representing the cross-sectional zero constraints. It spans the null space for the reconciled forecasts.

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

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

fh

Forecast horizon for the lowest frequency (most temporally aggregated) time series (default is 1).

sparse

Option to return sparse matrices (default is TRUE).

Value

A list with four elements:

dim

A vector containing information about the number of series for the complete system (n), for upper levels (na) and bottom level (nb), the maximum aggregation order (m), the number of factor (p), the partial (ks) and total sum (kt) of factors.

set

The vector of the temporal aggregation orders (in decreasing order).

agg_mat

The cross-temporal aggregation matrix.

strc_mat

The cross-temporal structural matrix.

cons_mat

The cross-temporal zero constraints matrix.

See also

Cross-temporal framework: ctboot(), ctbu(), ctcov(), ctlcc(), ctmo(), ctrec(), cttd(), iterec(), tcsrec()

Utilities: FoReco2matrix(), aggts(), balance_hierarchy(), commat(), csprojmat(), cstools(), ctprojmat(), df2aggmat(), lcmat(), recoinfo(), res2matrix(), shrink_estim(), teprojmat(), tetools(), unbalance_hierarchy()

Examples

# Cross-temporal framework
A <- t(c(1,1)) # Aggregation matrix for Z = X + Y
m <- 4 # from quarterly to annual temporal aggregation
cttools(agg_mat = A, agg_order = m)
#> $dim
#>  n na nb  m  p ks kt 
#>  3  1  2  4  3  3  7 
#> 
#> $set
#> [1] 4 2 1
#> 
#> $agg_mat
#> 13 x 8 sparse Matrix of class "dgCMatrix"
#>                      
#>  [1,] 1 1 1 1 1 1 1 1
#>  [2,] 1 1 . . 1 1 . .
#>  [3,] . . 1 1 . . 1 1
#>  [4,] 1 . . . 1 . . .
#>  [5,] . 1 . . . 1 . .
#>  [6,] . . 1 . . . 1 .
#>  [7,] . . . 1 . . . 1
#>  [8,] 1 1 1 1 . . . .
#>  [9,] 1 1 . . . . . .
#> [10,] . . 1 1 . . . .
#> [11,] . . . . 1 1 1 1
#> [12,] . . . . 1 1 . .
#> [13,] . . . . . . 1 1
#> 
#> $strc_mat
#> 21 x 8 sparse Matrix of class "dgCMatrix"
#>                      
#>  [1,] 1 1 1 1 1 1 1 1
#>  [2,] 1 1 . . 1 1 . .
#>  [3,] . . 1 1 . . 1 1
#>  [4,] 1 . . . 1 . . .
#>  [5,] . 1 . . . 1 . .
#>  [6,] . . 1 . . . 1 .
#>  [7,] . . . 1 . . . 1
#>  [8,] 1 1 1 1 . . . .
#>  [9,] 1 1 . . . . . .
#> [10,] . . 1 1 . . . .
#> [11,] 1 . . . . . . .
#> [12,] . 1 . . . . . .
#> [13,] . . 1 . . . . .
#> [14,] . . . 1 . . . .
#> [15,] . . . . 1 1 1 1
#> [16,] . . . . 1 1 . .
#> [17,] . . . . . . 1 1
#> [18,] . . . . 1 . . .
#> [19,] . . . . . 1 . .
#> [20,] . . . . . . 1 .
#> [21,] . . . . . . . 1
#> 
#> $cons_mat
#> 13 x 21 sparse Matrix of class "dgCMatrix"
#>                                                            
#>  [1,] . . .  1  .  .  . . . . -1  .  .  . . . . -1  .  .  .
#>  [2,] . . .  .  1  .  . . . .  . -1  .  . . . .  . -1  .  .
#>  [3,] . . .  .  .  1  . . . .  .  . -1  . . . .  .  . -1  .
#>  [4,] . . .  .  .  .  1 . . .  .  .  . -1 . . .  .  .  . -1
#>  [5,] 1 . . -1 -1 -1 -1 . . .  .  .  .  . . . .  .  .  .  .
#>  [6,] . 1 . -1 -1  .  . . . .  .  .  .  . . . .  .  .  .  .
#>  [7,] . . 1  .  . -1 -1 . . .  .  .  .  . . . .  .  .  .  .
#>  [8,] . . .  .  .  .  . 1 . . -1 -1 -1 -1 . . .  .  .  .  .
#>  [9,] . . .  .  .  .  . . 1 . -1 -1  .  . . . .  .  .  .  .
#> [10,] . . .  .  .  .  . . . 1  .  . -1 -1 . . .  .  .  .  .
#> [11,] . . .  .  .  .  . . . .  .  .  .  . 1 . . -1 -1 -1 -1
#> [12,] . . .  .  .  .  . . . .  .  .  .  . . 1 . -1 -1  .  .
#> [13,] . . .  .  .  .  . . . .  .  .  .  . . . 1  .  . -1 -1
#>