unbalance_hierarchy: Aggregation matrix of a balanced hierarchy in (possibly)...

View source: R/fun_export.R

unbalance_hierarchyR Documentation

Aggregation matrix of a balanced hierarchy in (possibly) unbalanced form

Description

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 a balanced hierarchy into an aggregation matrix of an unbalanced one, by removing possible duplicated series.

Usage

unbalance_hierarchy(agg_mat, more_info = FALSE, 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.

more_info

If TRUE, it returns only the aggregation matrix of the unbalanced hierarchy. Default is FALSE.

sparse

Option to return sparse matrices (default is TRUE).

Value

A list containing four elements (more_info = TRUE):

ubm

The aggregation matrix of the unbalanced hierarchy.

agg_mat

The input matrix.

idrm

The identification number of the duplicated variables (row numbers of the aggregation matrix agg_mat).

id

The identification number of each variable in the balanced hierarchy. It may contains duplicated values.

See Also

Utilities: FoReco2matrix(), aggts(), as_ctmatrix(), as_tevector(), balance_hierarchy(), commat(), csprojmat(), cstools(), ctprojmat(), cttools(), df2aggmat(), lcmat(), recoinfo(), res2matrix(), set_bounds(), shrink_estim(), shrink_oasd(), teprojmat(), tetools()

Examples

#     Balanced     ->     Unbalanced
#        T                    T
#    |-------|            |-------|
#    A       B            A       |
#  |---|     |          |---|     |
# AA   AB    BA        AA   AB    BA
A <- matrix(c(1, 1, 1,
              1, 1, 0,
              0, 0, 1), 3, byrow = TRUE)
obj <- unbalance_hierarchy(agg_mat = A)
obj

FoReco documentation built on March 12, 2026, 5:07 p.m.