Hello Stata Community;
I'm writing on this forum hoping I could get some help, because what I wanna do seemed a bit complicated, and perhaps not faisable aswell, but I'll try my best to explian my goal in the following.
I have this data:
It is basically 70 countries with their Economic Freedom score and their Gini index.
My goal is the following: Dividing the 70 countries into 2 groups:
-The first group is the more Economically Free countries according to the "Economic Freedom" variable
-The second group is the less Economically Free countries, again according to the "Economic Freedom" variable
The idea here is to get the 4 or 6 or 8 median countries of the whole 70 (it has to be a pair number so we could take an equal number of countries as medians from each sub-group) and to divide the 70 countries into less and more economically free, according to these 4 or 6 median countries.
Then, what I wanna draw is a bar graph with the Gini index for each country as the Y vertical axis, and for the X horizontal axis, I wanna have the bars of the sub-groups of countries (the less and the more economically free countries), so it's going to be a 2 graphs drawing into one graph, if you wanna say so. I don't need to show the names of the countries since they are going to be groped into two groups, but I wanna have the more economically free countries group (with their Gini index bars), and the same thing for the less economically free countries, both groups divided by these 4 or 6 median countries according to the economic freedom index.
As a start, I've tried these commands:
-graph bar (iqr) EconomicFreedom, over( Gini2017 , gap(10) sort(EconomicFreedom))
-graph bar (p10) EconomicFreedom, over( Gini2017 )
I guess this type of command is the right answer, but it just needs more options or something.
I hope I could get some help to draw the final graph that I wanna draw, either using the philosophy of those 2 commands, or other more sofisticated commands.
Thanks very much, community.
I'm writing on this forum hoping I could get some help, because what I wanna do seemed a bit complicated, and perhaps not faisable aswell, but I'll try my best to explian my goal in the following.
I have this data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str30 Country float(EconomicFreedom Gini2017) "Albania" 7.65 33.1 "Argentina" 4.72 41.1 "Armenia" 7.84 33.6 "Austria" 7.91 29.7 "Belgium" 7.85 27.4 "Bhutan" 6.75 37.4 "Bolivia" 6.25 44.6 "Brazil" 6.49 53.3 "Bulgaria" 7.62 40.4 "Canada" 8.29 33.3 "Chile" 7.91 44.4 "China" 6.21 39.1 "Colombia" 6.69 49.7 "Costa Rica" 7.64 48.3 "Croatia" 7.23 30.4 "Cyprus" 7.43 31.4 "Czech Republic" 7.93 24.9 "Denmark" 8.11 28.7 "Dominican Republic" 7.53 42.2 "Ecuador" 6.02 44.7 "Egypt, Arab Rep." 5.52 31.5 "El Salvador" 7.49 38 "Estonia" 8.05 30.4 "Finland" 7.92 27.4 "France" 7.72 31.6 "Gabon" 5.44 38 "Georgia" 8.31 37.9 "Germany" 7.96 31.2 "Greece" 7.17 34.4 "Honduras" 7.26 49.4 "Hungary" 7.51 30.6 "Iceland" 7.33 26.1 "Indonesia" 7.07 38.1 "Iran, Islamic Rep." 5.1 40.8 "Ireland" 8.24 31.4 "Israel" 7.58 38.2 "Italy" 7.67 35.9 "Kazakhstan" 7.14 27.5 "Kyrgyz Republic" 7.14 27.3 "Latvia" 8.12 35.6 "Lesotho" 6.55 44.9 "Lithuania" 8.08 37.3 "Luxembourg" 7.85 34.5 "Malta" 7.97 29.2 "Mauritius" 7.9 36.8 "Moldova" 7.01 25.9 "Montenegro" 7.39 36.9 "Myanmar" 5.75 30.7 "Netherlands" 7.94 28.5 "North Macedonia" 7.52 34.2 "Norway" 7.82 27 "Panama" 7.7 49.9 "Paraguay" 7.01 48.5 "Peru" 7.76 43.3 "Poland" 7.54 29.7 "Portugal" 7.74 33.8 "Romania" 7.91 36 "Russian Federation" 6.59 37.2 "Serbia" 6.78 36.2 "Slovak Republic" 7.7 23.2 "Slovenia" 7.31 24.2 "Spain" 7.75 34.7 "Sweden" 7.93 28.8 "Switzerland" 8.49 32.7 "Thailand" 6.56 36.5 "Ukraine" 5.96 26 "United Kingdom" 8.16 35.1 "United States" 8.18 41.2 "Uruguay" 7.26 39.5 "Zimbabwe" 5.9 44.3 end
My goal is the following: Dividing the 70 countries into 2 groups:
-The first group is the more Economically Free countries according to the "Economic Freedom" variable
-The second group is the less Economically Free countries, again according to the "Economic Freedom" variable
The idea here is to get the 4 or 6 or 8 median countries of the whole 70 (it has to be a pair number so we could take an equal number of countries as medians from each sub-group) and to divide the 70 countries into less and more economically free, according to these 4 or 6 median countries.
Then, what I wanna draw is a bar graph with the Gini index for each country as the Y vertical axis, and for the X horizontal axis, I wanna have the bars of the sub-groups of countries (the less and the more economically free countries), so it's going to be a 2 graphs drawing into one graph, if you wanna say so. I don't need to show the names of the countries since they are going to be groped into two groups, but I wanna have the more economically free countries group (with their Gini index bars), and the same thing for the less economically free countries, both groups divided by these 4 or 6 median countries according to the economic freedom index.
As a start, I've tried these commands:
-graph bar (iqr) EconomicFreedom, over( Gini2017 , gap(10) sort(EconomicFreedom))
-graph bar (p10) EconomicFreedom, over( Gini2017 )
I guess this type of command is the right answer, but it just needs more options or something.
I hope I could get some help to draw the final graph that I wanna draw, either using the philosophy of those 2 commands, or other more sofisticated commands.
Thanks very much, community.

Comment