Calculate additive quote contributions for a price index that nests two levels of generalized means, like the Fisher index, consisting of an outer generalized mean and an collection of inner generalized means.
A finite number giving the order of the outer generalized mean.
A vector of finite numbers giving the order of the inner generalized means.
A vector of numeric weights that weights each inner generalized mean in the outer generalized mean, the same length as
This function is the analog of
contributions() for a nested generalized mean with two levels, like a Fisher or Harmonic Laspeyres Paasche index. That is, it calculates the contribution of each element of
x when a generalized mean of order
r1, with weights
w1, aggregates a collection of generalized means of
x with orders in the list
r2, each with weights in the list
contributions_nested() returns a function:
function(x, w = rep(list(rep(1, length(x))), length(r2))).
This function takes a numeric vector
x and list of numeric weights
w, the same length as
r2, and returns the contribution for each element in
This function is experimental, and the interface may change in future versions.
contributions for contributions without nesting.
1 2 3 4 5 6 7 8 9 10 11 12
p1 <- price6[] p0 <- price6[] q1 <- quantity6[] q0 <- quantity6[] contributions_fisher <- contributions_nested(0, c(1, -1)) contributions_fisher(p1 / p0, list(index_weights("Laspeyres")(p0, q0), index_weights("Paasche")(p1, q1))) contributions_hlp <- contributions_nested(-1, c(1, -1)) contributions_hlp(p1 / p0, list(index_weights("Laspeyres")(p0, q0), index_weights("Paasche")(p1, q1)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.