balance_hierarchy | R Documentation |
A hierarchy with L
upper levels is said to be balanced if each variable at level
l
has at least one child at level l+1
. When this doesn't hold, the hierarchy
is unbalanced. This function transforms an aggregation matrix of an unbalanced hierarchy
into an aggregation matrix of a balanced one. This function is used to reconcile forecasts
with cslcc, which operates exclusively with balanced hierarchies.
balance_hierarchy(agg_mat, nodes = "auto", sparse = TRUE)
agg_mat |
A ( |
nodes |
A ( |
sparse |
Option to return sparse matrices (default is |
A list containing four elements:
bam |
The balanced aggregation matrix. |
agg_mat |
The input matrix. |
nodes |
A ( |
id |
The identification number of each variable in the balanced hierarchy. It may contains duplicated values. |
Utilities:
FoReco2matrix()
,
aggts()
,
commat()
,
csprojmat()
,
cstools()
,
ctprojmat()
,
cttools()
,
df2aggmat()
,
lcmat()
,
recoinfo()
,
res2matrix()
,
shrink_estim()
,
teprojmat()
,
tetools()
,
unbalance_hierarchy()
# Unbalanced -> Balanced
# T T
# |-------| |-------|
# A | A B
# |---| | |---| |
# AA AB B AA AB BA
A <- matrix(c(1, 1, 1,
1, 1, 0), 2, byrow = TRUE)
obj <- balance_hierarchy(agg_mat = A, nodes = c(1, 1))
obj$bam
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.