I'm computing the Gini coefficient in Stata 16 with the" ineqdeco" command. I'm using panel data from the Household Surveys in 2009, 2012, and 2016 with about 59,000 observations. I'd like to estimate the Gini coefficient for each household for each year, but the Gini coefficient is only generated for Household Code (grouped variable). As a result, each household has the same Gini coefficient over all three years. However, I want to calculate the Gini index for each household_Code for each year.
For example, the output appears as:
Year Household_Code Gini
2009 1 0.6456
2012 1 0.6456
2016 1 0.6456
2009 2 0.3423
2012 2 0.3423
2016 2 0.3423
Code:
egen Household_Code = group(District Psu Snumber) su Household_Code, meanonly gen gini = . program do_it qui ineqdeco Household_Income, by(Household_Code) replace gini = r(gini) end runby do_it, by(Household_Code) verbose
Code:
egen Household_Code = group(District Psu Snumber) su Household_Code, meanonly gen gini = . program do_it qui ineqdeco Household_Income, by(Year Household_Code) replace gini = r(gini) end runby do_it, by(Year Household_Code) verbose
0 Response to Constructing Gini Index for Household data
Post a Comment