Dear Statalist,
I recently learned that one of the ways to generate Gini Coefficient is to use ineqdeco command.
I wanted to directly include the derived Gini coefficient value as a variable such as below.
Using the above example data set, if I run the below code, I create a variable "gini_for_all" which includes the derived Gini coefficient from all the id(s) based on their income values.
But I am trying to take one step further; what I want to do is I want to generate Gini coefficient that is calculated for each group and include each within "gini_for_group" variable.
I thought "by group" or "bysort group" were going to work but the error message returned me "ineqdeco may not be combined with by".
Is there a clever way to address this?
Thank you.
I recently learned that one of the ways to generate Gini Coefficient is to use ineqdeco command.
I wanted to directly include the derived Gini coefficient value as a variable such as below.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(group id income) 1 1 0 1 2 5000 1 3 12000 1 4 18000 2 5 30000 2 6 40000 2 7 60000 3 8 100000 3 9 150000 end
Code:
ineqdeco income gen gini_for_all=r(gini)
I thought "by group" or "bysort group" were going to work but the error message returned me "ineqdeco may not be combined with by".
Is there a clever way to address this?
Thank you.
Comment