I know that the variance can be decomposed into within- and between-group components.
Let $Y$ be a vector and $Y_{i}$ and be a subgroup of $Y$ and we have $I$ subgroups, then
$Var_{T}(Y)=Var_{W}(Y)+Var_{B}(Y)$ with
$Var_{W}=\sum_{i=1}^{I}\frac{1}{n_{i}}*Var(Y_{i})$ and $Var_{B}=\sum_{i=1}^{I}\frac{1}{n_{i}}(Mean(Y_{i})-Mean(Y))^{2}$, where $n_{i}$ is the size of group $i$.
According to Cowell (2011: 74) "Measuring inequality", the coefficient of variation can likewise be decomposed into within- and between-group components.
However, when I decompose the CV like this:
$CV_{W}=\sum_{i=1}^{I}\frac{1}{n_{i}}*\frac{\sqrt{Var(Y_{i})}}{Mean(Y_{i})}$ and $CV_{B}=\sum_{i=1}^{I}\frac{1}{n_{i}}\frac{\sqrt{(Mean(Y_{i})-Mean(Y))^{2}}}{Mean(Y)}$,
the sum of within- and between-group CV is not exactly the total coefficient of variation.
Here some R code to replicate the problem:
# Create data (three groups)
set.seed(1)
n <- 10000
y1 <- rnorm(n, 10, 10)
y2 <- rnorm(n, 1000, 5)
y3 <- rnorm(n, 30, 1)
y <- c(y1, y2, y3)
# Variance
var_w <- 1/3*var(y1)+1/3*var(y2)+1/3*var(y3)
var_b <- var_b <- 1/3*(mean(y1)-mean(y))^2+1/3*(mean(y2)-mean(y))^2+1/3*(mean(y3)-mean(y))^2
var_w+var_b # 213538
var(y) # 213538
# Coefficient of variation
cv_y1 <- sqrt(var(y1))/mean(y1)
cv_y2 <- sqrt(var(y2))/mean(y2)
cv_y3 <- sqrt(var(y3))/mean(y3)
cv_w <- 1/3 *cv_y1 + 1/3*cv_y2 + 1/3 * cv_y3
cv_b <- sqrt(var_b)/mean(y)
cv_w+cv_b # 1.69
sqrt(var(y))/mean(y) # 1.33
The two values are close enough (also true for different distributions of Y) to make me think that there might be a simple correction factor.
How can I decompose the coefficient of variation into within- and between-group components?