I am trying to create lorenz curves for a variable with four categories. I have done this before but this time my curves are coming out as straight lines. I am sharing an example dataset along with my commands.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float raw_rank1 byte v190 float(sei z) double rank float rank2 1519 2 -.57867503 0 .438 .438 1521 2 -.57797277 0 .439 .439 890 1 -.8061847 0 .273 .273 2461 2 .0007149702 0 .655 .655 2061 2 -.28932393 0 .56 .56 2988 3 .4960965 0 .763 .763 1394 2 -.6336712 0 .407 .407 119 1 -1.0780907 0 .045 .045 1511 2 -.5812709 0 .435 .435 158 1 -1.0511917 0 .057 .057 3132 3 .6742755 0 .805 .805 1028 1 -.7624822 0 .311 .311 1493 2 -.5876991 0 .431 .431 1592 2 -.5417551 0 .451 .451 3225 3 .8141427 0 .822 .822 1406 2 -.6303535 0 .409 .409 1921 2 -.3819044 0 .526 .526 266 1 -1.0056158 0 .092 .092 2282 2 -.14398591 0 .611 .611 11 1 -1.223736 0 .001 .001 66 1 -1.1141272 0 .027 .027 3905 3 2.594721 0 .983 .983 1562 2 -.5555258 0 .446 .446 212 1 -1.0261097 0 .075 .075 277 1 -1.0024703 0 .098 .098 3750 3 1.9207685 0 .949 .949 114 1 -1.080746 0 .044 .044 414 1 -.9529806 0 .141 .141 1021 1 -.7646693 0 .308 .308 3956 3 2.976368 0 .992 .992 2139 2 -.2403019 0 .576 .576 872 1 -.8127694 0 .267 .267 1201 1 -.7066278 0 .357 .357 42 1 -1.1533086 0 .019 .019 1211 1 -.7038143 0 .359 .359 673 1 -.8647565 0 .215 .215 61 1 -1.119929 0 .024 .024 2684 3 .1753951 0 .7 .7 2035 2 -.3084227 0 .552 .552 1706 2 -.4945633 0 .477 .477 106 1 -1.0862021 0 .041 .041 445 1 -.9433951 0 .15 .15 3025 3 .53929883 0 .775 .775 3368 3 1.0676816 0 .868 .868 2483 2 .011977144 0 .658 .658 1341 2 -.6609402 0 .392 .392 123 1 -1.07341 0 .047 .047 3627 3 1.5838754 0 .929 .929 942 1 -.7906448 0 .286 .286 2722 3 .20741607 0 .71 .71 3233 3 .8326448 0 .823 .823 1628 2 -.52488875 0 .461 .461 2923 3 .4188752 0 .753 .753 3454 3 1.2099286 0 .89 .89 1757 2 -.4668162 0 .489 .489 1435 2 -.6137782 0 .416 .416 2478 2 .008811969 0 .657 .657 3957 3 2.99273 0 .993 .993 1430 2 -.6182839 0 .414 .414 964 1 -.7837582 0 .292 .292 1427 2 -.6187509 0 .412 .412 927 1 -.795358 0 .282 .282 1634 2 -.5228623 0 .463 .463 645 1 -.8762712 0 .206 .206 3474 3 1.252518 0 .894 .894 2442 2 -.012976546 0 .65 .65 735 1 -.8494613 0 .237 .237 1143 1 -.7286108 0 .345 .345 2302 2 -.1215786 0 .617 .617 1652 2 -.5176178 0 .467 .467 561 1 -.9010396 0 .187 .187 3317 3 .9688857 0 .854 .854 73 1 -1.1084094 0 .03 .03 3866 3 2.3716063 0 .973 .973 319 1 -.9914252 0 .11 .11 2440 2 -.013812775 0 .649 .649 26 1 -1.1747433 0 .012 .012 258 1 -1.0091702 0 .089 .089 1556 2 -.5576935 0 .445 .445 322 1 -.990563 0 .112 .112 2132 2 -.24586444 0 .574 .574 801 1 -.8318206 0 .254 .254 711 1 -.856173 0 .229 .229 2699 3 .19003813 0 .705 .705 3192 3 .7619695 0 .819 .819 1226 1 -.6974397 0 .365 .365 1607 2 -.53420997 0 .454 .454 3172 3 .72391 0 .812 .812 2609 2 .10445177 0 .685 .685 1983 2 -.3496844 0 .54 .54 3392 3 1.1001801 0 .874 .874 3078 3 .6023574 0 .789 .789 734 1 -.8496683 0 .236 .236 1976 2 -.3590761 0 .537 .537 2136 2 -.24302575 0 .575 .575 2604 2 .10296789 0 .682 .682 17 1 -1.1979523 0 .006 .006 1433 2 -.6150438 0 .415 .415 1774 2 -.454978 0 .496 .496 3412 3 1.1337353 0 .879 .879 end label values v190 wlth
Code:
pca x1-x74 predict comp1 rename comp1 v191 regr y v191 i.z drop if e(sample)!=1 glcurve y , pvar(rank) glvar(Lorenz) sortvar(v191) replace by(z) split saving(v191_graph)
I also tried using a standardized wealth index but it is not working either.
Code:
egen sei=std(v191) regr y sei i.z drop if e(sample)!=1 glcurve y , pvar(rank) glvar(Lorenz) sortvar(sei) replace by(z) split saving(sei_graph)
Thanks in advance
Deepali
Array Array
0 Response to My Lorenz curves are coming out as straight lines.
Post a Comment