I calculated the Gini coefficient through a statistical program (MATLAB), and it came out much larger than I expected. I think I got the Gini coefficient formula right, but I don't know where I went wrong. Here's my calculation process. (I used file 1 with income, household size, and quarters table (1990/1Q-2022/4Q) and file 2 with CPI (2020=100)).
Step1
Calculating real income: dividing each the income by the CPI for corresponding quarter and multiply by 100.
Step2
Equalizing income: dividing the value obtained above by the square root of the number of household members.
Step3
Adding the number of people in the household for all households with the same income.
Step4
Calculating the Gini coefficient according to the following formula
Formula
$$ \frac{\sum_{i=1}^n f(Y_i) \sum_{j=1}^n f(Y_j)\vert Y_i-Y_j\vert}{2\bar Y} $$
where $Y_i$is the income of ith household, $f(Y_i)$ is the frequency of the people of income, and $\bar{Y}=\sum_{i=1}^{n}{f\left(Y_i\right)Y_i}$
I'm having a hard time keeping up with the reviews. Thank you for your help. I will share the MATLAB code if needed.