When working with a general linearly constrained multiple (n-variate) time series
(x_t), getting a linear combination matrix
C is a critical step to obtain a structural-like
representation such that, for t = 1, ..., T,
U'= [I -C]
y_t = Px_t = [arrayc
v_t
f_t
array] = [arrayc
C
I
array]f_t = Sf_t,
where U' is the (n_v n) full rank zero constraints matrix,
S is the (n n_f) matrix analogous of the summing matrix
S for a genuine hierarchical/groupped times series,
C is the (n_v n_f) linear combination matrix
such that v_t = Cf_t,
v_t is the (n_v 1) vector of ‘basic’ variables, and
f_t is the (n_f 1) vector of ‘free’ variables
(Di Fonzo and Girolimetto, 2022).
lcmat(Gt, alg = "rref", tol = sqrt(.Machine$double.eps),
verbose = FALSE, sparse = TRUE)
A list with
Cbar
(n_v n_f) linear combination matrix C
pivot
(n 1) vector of the column permutations s.t. P = I[,pivot]
(r n) coefficient matrix (') for a general linearly constrained multiple time series (x_t) such that 'x_t = 0_(r 1).
Technique used to trasform ' in
U' = [I -C], such that
U'y_t = 0_(n_v 1). Use
"rref"
for the Row Reduced Echelon Form through Gauss-Jordan elimination
(default), or "qr"
for the (pivoting) QR decomposition (Strang, 2019).
Tolerance for the "rref"
or "qr"
algorithm.
If TRUE
, intermediate steps are printed (default is FALSE
).
Option to return a sparse C
matrix (default is TRUE
).
Looking for an analogous of the summing matrix S, say
S = [arrayc
C
I
array], the lcmat
function transforms ' into
U' = [I -C], such that
U'y_t = 0_(n_v 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 (X):
arrayl
1)\; X = C + D,
2)\; X = A + B,
3)\; A = A1 + A2.
array
The coefficient matrix ' of the linear system
'x_t=0
(x_t = [X\; C\; D\; A\; B\; A1\; A2]) is
' = [arrayccccccc
1 & -1 & -1 & 0 & 0 & 0 & 0
1 & 0 & 0 & -1 & -1 & 0 & 0
0 & 0 & 0 & 1 & 0 & -1 & -1
array].
The lcmat function returns
C = [arraycccc
0 & 1 & 1 & 1
-1 & 1 & 1 & 1
0 & 0 & -1 & -1
array].
Then
U' = [arrayccc|cccc
1 & 0 & 0 & 0 & -1 & -1 & -1
0 & 1 & 0 & 1 & -1 & -1 & -1
0 & 0 & 1 & 0 & 0 & 1 & 1
array], with
U'y_t = U' [arrayc
v_t
f_t
array] = 0,
where v_t = [X\; C\; A], and
f_t = [D\; B\; A1\; A2].
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.
Other utilities:
Cmatrix()
,
FoReco2ts()
,
agg_ts()
,
arrange_hres()
,
commat()
,
ctf_tools()
,
hts_tools()
,
oct_bounds()
,
residuals_matrix()
,
score_index()
,
shrink_estim()
,
thf_tools()
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]
Run the code above in your browser using DataLab