lcmat: Linear Combination Matrix for a general linearly constrained...

View source: R/lcmat.R

lcmatR Documentation

Linear Combination Matrix for a general linearly constrained multiple time series

Description

\loadmathjax

When working with a general linearly constrained multiple (\mjseqnn-variate) time series (\mjseqn\mathbfx_t), getting a linear combination matrix \mjseqn\bar\mathbfC is a critical step to obtain a structural-like representation such that, for \mjseqnt = 1, ..., T, \mjsdeqn\bar\mathbfU'= [\mathbfI \quad -\bar\mathbfC] \quad \Rightarrow \quad \mathbfy_t = \mathbfP\mathbfx_t = \left[\beginarrayc \mathbfv_t
\mathbff_t \endarray\right] = \left[\beginarrayc \mathbf\bar\mathbfC
\mathbfI \endarray\right]\mathbff_t = \mathbf\bar\mathbfS\mathbff_t, where \mjseqn\bar\mathbfU' is the (\mjseqnn_v \times n) full rank zero constraints matrix, \mjseqn\bar\mathbfS is the (\mjseqnn \times n_f) matrix analogous of the summing matrix \mjseqn\mathbfS for a genuine hierarchical/groupped times series, \mjseqn\bar\mathbfC is the (\mjseqnn_v \times n_f) linear combination matrix such that \mjseqn\mathbfv_t = \bar\mathbfC\mathbff_t, \mjseqn\mathbfv_t is the (\mjseqnn_v \times 1) vector of ‘basic’ variables, and \mjseqn\mathbff_t is the (\mjseqnn_f \times 1) vector of ‘free’ variables (Di Fonzo and Girolimetto, 2022).

Usage

lcmat(Gt, alg = "rref", tol = sqrt(.Machine$double.eps),
       verbose = FALSE, sparse = TRUE)

Arguments

Gt

(\mjseqnr \times n) coefficient matrix (\mjseqn\mathbf\Gamma') for a general linearly constrained multiple time series (\mjseqn\mathbfx_t) such that \mjseqn\mathbf\Gamma'\mathbfx_t = \mathbf0_(r \times 1).

alg

Technique used to trasform \mjseqn\mathbf\Gamma' in \mjseqn\bar\mathbfU' = [\mathbfI \quad -\bar\mathbfC], such that \mjseqn\bar\mathbfU'\mathbfy_t = \mathbf0_(n_v \times 1). Use "rref" for the Row Reduced Echelon Form through Gauss-Jordan elimination (default), or "qr" for the (pivoting) QR decomposition (Strang, 2019).

tol

Tolerance for the "rref" or "qr" algorithm.

verbose

If TRUE, intermediate steps are printed (default is FALSE).

sparse

Option to return a sparse \mjseqn\bar\mathbfC matrix (default is TRUE).

Details

Looking for an analogous of the summing matrix \mjseqn\mathbfS, say \mjseqn\bar\mathbfS = \left[\beginarrayc \mathbf\bar\mathbfC
\mathbfI \endarray\right], the lcmat function transforms \mjseqn\mathbf\Gamma' into \mjseqn\bar\mathbfU' = [\mathbfI \quad -\bar\mathbfC], such that \mjseqn\bar\mathbfU'\mathbfy_t = \mathbf0_(n_v \times 1). Consider the simple example of a linearly constrained multiple time series consisting of two hierarchies, each with distinct bottom time series, with a common top-level series (\mjseqnX): \mjsdeqn\beginarrayl 1)\; X = C + D,
2)\; X = A + B,
3)\; A = A1 + A2. \endarray The coefficient matrix \mjseqn\mathbf\Gamma' of the linear system \mjseqn\mathbf\Gamma'\mathbfx_t=\mathbf0 (\mjseqn\mathbfx_t = [X\; C\; D\; A\; B\; A1\; A2]) is \mjsdeqn\mathbf\Gamma' = \left[\beginarrayccccccc 1 & -1 & -1 & 0 & 0 & 0 & 0
1 & 0 & 0 & -1 & -1 & 0 & 0
0 & 0 & 0 & 1 & 0 & -1 & -1 \endarray\right]. The lcmat function returns \mjsdeqn\bar\mathbfC = \left[\beginarraycccc 0 & 1 & 1 & 1
-1 & 1 & 1 & 1
0 & 0 & -1 & -1 \endarray\right]. Then \mjsdeqn\bar\mathbfU' = \left[\beginarrayccc|cccc 1 & 0 & 0 & 0 & -1 & -1 & -1
0 & 1 & 0 & 1 & -1 & -1 & -1
0 & 0 & 1 & 0 & 0 & 1 & 1 \endarray\right], \quad \mboxwith \quad \bar\mathbfU'\mathbfy_t = \bar\mathbfU' \left[\beginarrayc \mathbfv_t
\mathbff_t \endarray\right] = \mathbf0, where \mjseqn\mathbfv_t = [X\; C\; A], and \mjseqn\mathbff_t = [D\; B\; A1\; A2].

Value

A list with

Cbar

(\mjseqnn_v \times n_f) linear combination matrix \mjseqn\bar\mathbfC

pivot

(\mjseqnn \times 1) vector of the column permutations s.t. \mjseqn\mathbfP = \mathbfI[,\mboxpivot]

References

Di Fonzo, T., Girolimetto, D. (2022), Point and probabilistic forecast reconciliation for general linearly constrained multiple time series (mimeo).

Strang, G., (2019), Linear algebra and learning from data, Wellesley, Cambridge Press.

See Also

Other utilities: Cmatrix(), FoReco2ts(), agg_ts(), arrange_hres(), commat(), ctf_tools(), hts_tools(), oct_bounds(), residuals_matrix(), score_index(), shrink_estim(), thf_tools()

Examples

Gt <- matrix(c(1,-1,-1,0,0,0,0,
               1,0,0,-1,-1,0,0,
               0,0,0,1,0,-1,-1), nrow = 3, byrow = TRUE)
Cbar <- lcmat(Gt = Gt)$Cbar
P <- diag(1, NCOL(Gt))[,lcmat(Gt = Gt)$pivot]


FoReco documentation built on May 31, 2023, 5:17 p.m.