Learn R Programming

FoReco (version 1.0.0)

unbalance_hierarchy: 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)

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.

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

See Also

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

Examples

Run this code
#     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

Run the code above in your browser using DataLab