pias_matrix: Make a PIAS matrix

Description Usage Arguments Details Value See Also Examples

Description

Make a PIAS matrix from a list that gives the aggregation structure and a vector of weights for each EA.

Usage

1
pias_matrix(x, w, na.rm = FALSE, sparse = FALSE)

Arguments

x

A list that gives the aggregation structure by specifying which EAs belong at each level of aggregation.

w

A vector of (numeric) weights for each EA.

na.rm

Should missing values be removed?

sparse

Should the result be a sparse matrix from Matrix?

Details

This function essentially takes the Hadamard product of a matrix where each column is w and a selector matrix formed with x, rescales each column so that it sums to 1, and returns the transpose. The ij-th value in this matrix is the value of the weight for the j-th EA in the i-th group of the PIAS.

Value

A matrix with a row for each level in the PIAS and a column for each EA.

See Also

See pias_class for an easy way to build x.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Elemental indices
index <- c(a = 1.1, b = 0.9, c = 1.15, d = 1.2)

# Weights for each EA
weights <- c(a = 0.25, b = 0.2, c = 0.15, d = 0.4)

# Aggregation structure with 3 levels
agg <- list(smaller = c('a', 'b'), larger = c('c', 'd'), total = c('a', 'b', 'c', 'd'))

# Make the PIAS
pias <- pias_matrix(agg, weights)

# Calculate an arithmetic index for each level in the PIAS
(pias %*% index)[, 1]

# Calculate a geometric index for each level in the PIAS
exp(pias %*% log(index))[, 1]

# Calculate a Paasche if weights are current-period expenditure/revenue shares
(1 / (pias %*% (1 / index)))[, 1]

# Also works with indices over several periods
index2 <- c(a = 1.2, b = 1, c = 1.1, d = 1.4)
pias %*% cbind(p1 = index, p2 = index2)

marberts/ppd documentation built on March 27, 2020, 7:21 p.m.