x <- 1:3
w1 <- 4:6
w2 <- 7:9
# A function to make the superlative quadratic mean price index as
# a product of generalized means.
quadratic_mean_index <- function(r) nested_mean(0, c(r / 2, -r / 2))
quadratic_mean_index(2)(x, w1, w2)
fisher_mean(x, w1, w2)
# The (arithmetic) Walsh index is the implicit price index when using a
# superlative quadratic mean quantity index of order 1.
p2 <- price6[[2]]
p1 <- price6[[1]]
q2 <- quantity6[[2]]
q1 <- quantity6[[1]]
walsh <- quadratic_mean_index(1)
sum(p2 * q2) / sum(p1 * q1) / walsh(q2 / q1, p1 * q1, p2 * q2)
sum(p2 * sqrt(q2 * q1)) / sum(p1 * sqrt(q2 * q1))
# Counter to the PPI manual (par. 1.105), it is not a superlative
# quadratic mean price index of order 1.
walsh(p2 / p1, p1 * q1, p2 * q2)
# That requires using the average value share as weights.
walsh_weights <- sqrt(scale_weights(p1 * q1) * scale_weights(p2 * q2))
walsh(p2 / p1, walsh_weights, walsh_weights)
Run the code above in your browser using DataLab