View source: R/aggregation_structure.R
aggregation_structure | R Documentation |
Create a price index aggregation structure from a hierarchical classification and aggregation weights that can be used to aggregate elemental indexes.
aggregation_structure(x, weights = NULL)
x |
A list of character vectors that give the codes/labels for each
level of the classification, ordered so that moving down the list goes down
the hierarchy. The last vector gives the elemental aggregates, which should
have no duplicates. All vectors should be the same length, without
|
weights |
A numeric vector of aggregation weights for the elemental
aggregates (i.e., the last vector in |
A price index aggregation structure of class piar_aggregation_structure
.
This is a list-S3 class with the following components.
child |
A nested list that gives the positions of the immediate children for each node in each level of the aggregation structure above the terminal nodes. |
parent |
A list that gives the position of the immediate parent for each node of the aggregation structure below the initial nodes. |
levels |
A named list of character vectors that give the levels of |
weights |
A vector giving the weight for each elemental aggregate. |
The aggregation_structure()
function does its best
to check its arguments, but there should be no expectation that the result
of aggregation_structure()
will make any sense if x
does not
represent a nested hierarchy.
aggregate()
to aggregate price indexes made
with elemental_index()
.
expand_classification()
to make x
from a character
representation of a hierarchical aggregation structure.
as_aggregation_structure()
to coerce tabular data into an
aggregation structure.
as.data.frame()
and
as.matrix()
to coerce an
aggregation structure into a tabular form.
weights()
to get the
weights for an aggregation structure.
update()
for updating a
price index aggregation structure with an aggregated index.
# A simple aggregation structure
# 1
# |-----+-----|
# 11 12
# |---+---| |
# 111 112 121
# (1) (3) (4)
aggregation_weights <- data.frame(
level1 = c("1", "1", "1"),
level2 = c("11", "11", "12"),
ea = c("111", "112", "121"),
weight = c(1, 3, 4)
)
aggregation_structure(
aggregation_weights[1:3],
weights = aggregation_weights[[4]]
)
# The aggregation structure can also be made by expanding the
# elemental aggregates
with(
aggregation_weights,
aggregation_structure(expand_classification(ea), weight)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.