Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • histogram for continuous variable

    Hello, I'm new in the forum and have a question for you.

    I work with panel data coming from a research network. The underlying firm-level raw data of each member country is confidential. Therefore and for reasons of comparability, the data is pooled and aggregated at different sector levels. However, the data set available to me does not only contain the respective mean values, but all values of the underlying distribution created during the aggregation.

    In order to show as part of my analysis how the distribution of a variable has changed over time per sector or country, I would like to present it graphically.

    Since I have all relevant properties of the distribution per country/year/sector as own variables, I am looking for a way to calculate different kernels by interpolating the available moments of the distribution.

    I am in the field of kernel density estimation, but due to the unusual approach I lack the idea for a further approach.
    I know I could plot the 10th and 90th percentile over time, but a typical view of a distribution would be more appropriate.

    I hope I have created a good data example and am looking forward to your suggestions.

    Data example:

    Info:
    variable_p1 = value at 1st percentile, variable_p10 = value ar 10st percentile,
    variable_sd = standard deviation,
    variable_skew = skewness
    variable_iqr = interquartile range.
    Code:
    input str13 country byte sector int year float(variable_iqr variable_mean variable_p1 variable_p10 variable_p20 variable_p30 variable_p40 variable_p50 variable_p60 variable_p70 variable_p80 variable_p90 variable_p99 variable_sd variable_skew)
    "country1" 1 2002  .08316796    .04337303    -.2269545     -.0532232    -.011277346   .010716712   .02375466  .03676545  .05130272  .07306185    .100204  .15511613  .3231776  .09509224  .10951895
    "country1" 1 2003  .08760485    .04784622     -.238902    -.05387203    -.006918778   .012898994  .026654657  .04035446    .055961   .0764264  .11114395  .16308586  .3396377  .09903994  -.1742165
    "country1" 1 2004  .09420463    .05783209    -.2124942    -.04086492   .00027718392    .01729789  .031905305  .04634453  .06357674  .08829361  .12173408  .18030873  .3410014   .0994368   .2256225
    "country1" 1 2005  .09012224    .05646351   -.20423368    -.03779425   -.0001217368    .01812411   .03113085   .0444632  .05982694   .0839219  .11683664   .1784417  .3368082  .09902152  .18024056
    "country1" 1 2006  .09225135    .06384529   -.20904528   -.029345926     .005902195   .022295317  .036943417  .05125748  .06885449  .09295981  .12435046   .1867929  .3494133  .10115737  .08973073
    "country1" 1 2007   .0944089    .07030966     -.200514    -.02299091      .01086669    .02682073   .04079077  .05686638   .0752304  .09839115  .13225667  .19800973  .3731743  .10323163   .1156162
    "country1" 1 2008  .08910593    .05157742   -.21418253     -.0472291   -.0039400365   .014217508   .02860503  .04301681  .05936781  .08179826  .11261054   .1664505  .3475431  .10136232 .017438319
    "country1" 1 2009  .08879016    .03437477   -.29379678    -.08138897    -.023671916   .004407109   .02002304 .033010032  .04734708   .0693822  .10187984   .1594217  .3151034  .10845645  -.4760354
    "country1" 1 2010   .0844996    .04771335   -.24874413    -.05143419    -.003691586   .013759927  .025977327   .0409242  .05654737   .0774783  .10947449  .16915904  .3276501   .1016138 -.16067374
    "country1" 1 2011  .08636101    .04614235    -.2490693    -.05100594    -.005127077   .012980284  .025043065  .03815276  .05374928   .0765989   .1099275  .16314936  .3277772  .10166649  -.6308886
    "country1" 1 2012  .08054356    .03675485   -.28166053    -.06294364    -.013115568   .008894721   .02022787  .03260161  .04678672  .06719011  .09600998  .14604461  .3096482  .10228572  -.8992358
    "country1" 1 2013  .08239385    .03785191    -.2814472    -.06107039    -.010723745    .00920183  .021132715 .033136528  .04934089 .070009016  .10093711   .1498375  .3013457  .10366511  -1.341187
    "country1" 2 2002   .0627019    .04205047   -.21945067    -.02454038    .0022463268   .015738012  .027031057 .037169337  .04849279  .06162702  .08641662  .13134596 .28052965  .07667319 -.16070695
    "country1" 2 2003  .06768013    .04924818   -.15363346   -.018322797     .006698778    .01925186  .029402364  .03931371  .05147231  .06820378  .09342184  .13676676  .2991673   .0759141   .3789564
    "country1" 2 2004  .07669906    .05618588   -.17210683   -.021223376     .008581352    .02094011  .031564146  .04406964  .05790789  .07693617  .10467806  .15257367 .32345095   .0832039   .5413909
    "country1" 2 2005  .07938947     .0593927   -.15541866   -.014345991     .009026434   .021831963  .033671267  .04741229  .06235425  .08438019  .11383524    .162495  .3179156  .08249186     .51414
    "country1" 2 2006  .08062854    .06692433    -.1634248   -.007388396      .01581779    .02819534   .04043319  .05365132 .069686465   .0892066  .11928416   .1741597  .3126176  .08454597    .528312
    "country1" 2 2007  .09292187    .07860535   -.12440933   .0007235563      .01909636   .032941516   .04591584  .06205329  .07874315  .10215499  .13848025  .19510522  .3539599  .08743784   .7980635
    "country1" 2 2008  .08772802    .06958125    -.1865783   -.008987294     .017663434     .0319069   .04312719  .05589181 .074084274  .09711093  .13075656   .1784043  .3147029  .08887393   .1916717
    "country1" 2 2009   .0889101    .06163063    -.1977266    -.02440864     .011642433   .023244144  .035444267  .04906999 .066813014  .09074421  .12116195   .1783725  .3230658  .09310164  .10526872
    "country1" 2 2010  .08982925    .06084604   -.21244177      -.024445       .0070021    .02130875   .03324448   .0470635  .06268345   .0862064  .12098616  .17573553  .3419302  .09353782   .4644793
    "country1" 2 2011    .076959    .06246951   -.18848687   -.014638877     .013150398    .02579413  .035470698  .04758143  .06011051  .08371626  .11570573  .16803536  .3714702  .09028005    .640537
    "country1" 2 2012   .0804705    .05511247    -.2059107    -.02659491     .005919102   .020455085  .032167558  .04330483   .0579785  .07891664  .11019504   .1662839   .327923  .08979089  .22075145
    "country1" 2 2013  .07554326    .05154622    -.1689675    -.03370087      .00490463   .016947856   .02757569   .0387764  .05649577  .07565322  .10286155   .1515765  .3350163  .08709578  .53367597
    "country1" 3 2003  .09122849    .06262818   -.24306075   -.029420825    .0040391153   .020477816   .03497442  .04903678  .06679774   .0896233   .1249305  .18992163  .3666023  .10096576  .28096178
    "country1" 3 2004  .10078674    .07252583   -.25016567    -.02256427     .010115304    .02655589   .04055826  .05832082  .07551766   .1041439  .14055352  .20828202  .3658466  .10598885   .1510424
    "country1" 3 2005  .09898855    .07094148    -.2065635   -.024892705      .00942316   .025966566   .04005685  .05577689  .07391926   .0998694  .13980938  .20363896  .3806957  .10238758   .4343913
    "country1" 3 2006  .10291824    .07835442    -.1961883    -.01611834     .014111687    .03071813   .04509662  .06032554  .08240695  .10994664   .1477315   .2053013  .4150353   .1034448  .51013935
    "country1" 3 2007  .10522886    .08325966    -.1678477    -.00976805     .016769616   .033359308   .04827565 .065436356  .08835565  .11481205   .1506843   .2136377  .3911152  .10064045   .6011094
    "country1" 3 2008  .09703624    .06579248    -.2225323    -.02544917     .005734273   .023424465   .03765804  .05235993 .070648946   .0961218  .13066387   .1872563  .3659742    .100927   .0264542
    "country1" 3 2009   .0913311    .06082537   -.20352305   -.032934334     .003458004    .01892804  .033576917  .04834393  .06575807  .08977359  .12545522   .1827074  .3554281  .09734005   .3680397
    "country1" 3 2010  .09285816    .06818405    -.1732493   -.018079871     .010569886    .02504931   .03881498  .05368638  .07305725  .09603573  .12871188  .18236166  .3662269  .09531443   .4595095
    "country1" 3 2011  .08910906    .06567094   -.21523927   -.018034656     .009165896    .02333628  .037206687  .05158065  .07111476  .09325614  .12179398  .18044484 .37819275   .0956796    .459604
    "country1" 3 2012  .08633114    .05410804    -.2125947    -.02891541    .0017645848    .01650355   .02816639  .04203522  .05897056   .0816034  .11296052  .16214398  .3292475  .09428854    .224693
    "country1" 3 2013   .0834767    .05123372    -.2387874    -.03119109    .0019640152    .01536021   .02625349  .04114122  .05806222  .07941144  .10745727   .1608692  .3421259  .09801974  -.4414992
    "country1" 4 2002   .0761424    .04321241     -.177959    -.03989331    -.005459618   .011226195  .025578195 .035309874  .05130946  .06777202  .09763467  .13936985 .26399398  .08202033  .08701523
    "country1" 4 2003  .08296005    .04989164     -.249568    -.03377722    -.001527387   .015984016  .028352024   .0409112  .05579127  .07867818  .11061735  .15606412 .32728675  .09541795  -.1603687
    "country1" 4 2004  .08324701    .05306102   -.25195894    -.03727824     -.00247604   .016100459  .028765943  .04168353  .05927675   .0811041  .11040893   .1646192   .340127  .09729557  .48081565
    "country1" 4 2005  .08302285     .0516314    -.1826295     -.0373856   -.0032770515   .013688901   .02764646  .03913922  .05523873  .07526898  .10469875   .1656168  .3512687  .09299619   .8096488
    "country1" 4 2006  .07876872    .05608401   -.19670513   -.022336854     .007244009    .01963087  .031917892  .04411551  .05823285  .07945644   .1130261  .16178103  .3195939   .0882971  .10611613
    "country1" 4 2007  .08401462   .062558375   -.14115284    -.01857368     .008588405   .022717465   .03380351  .04705557  .06309705  .08109027  .11451538  .17888045  .3670835  .09380407  .17359707
    "country1" 4 2008   .0767868    .04051908   -.22466592    -.04930649     -.01111339   .006674293  .021993525 .035296552   .0464601  .06375654   .0920365  .14876674   .317237   .0949736 -.20016664
    "country1" 4 2009  .07985446    .02432179   -.28827405    -.07491066    -.028332643 -.0014370215  .014198358  .02642919  .03908671  .05639958  .08587336  .12950477 .26133117  .10249417  -1.857381
    "country1" 4 2010   .0771031   .033876687   -.25494134     -.0571739    -.013892468   .006264115   .01889995 .031646583  .04544014  .06087434  .08839293  .13732244 .27799308  .09087478  -.4032592
    "country1" 4 2011  .07228889   .036778066    -.2190525    -.05432998    -.007518314   .009173376   .02291244 .031688064  .04528688  .06134728   .0875039  .13274461 .26848385  .08566634  .07688054
    "country1" 4 2012  .07312051    .03146846   -.24487136    -.05917589     -.01378863  .0043033287   .01992145  .03029441  .04345836  .05948703  .08526755  .13196686 .24860907  .08567636  -.3801258
    "country1" 4 2013 .070701174    .03560501    -.2621918     -.0415739    -.002698769   .010468404   .02260456 .033873614  .04626832 .062856644   .0882164  .12761183 .25532335  .08643822  -1.339375
    "country1" 5 2002  .07495708    .02520862   -.54284286    -.09241012    -.015848434   .014829884   .02973453 .036501102   .0503041 .065220065  .10102759  .13520499  .2712313  .13938561 -1.8459368
    "country1" 5 2003  .09014196    .01702821    -.5254196    -.11733481    -.021822996 -.0003664067   .01762901  .03256086  .04661847  .06621059   .0886427    .138838 .23224524  .12431087  -2.059987
    "country1" 5 2004  .07836258   .030706225     -.486733     -.0643566    -.013809043   .008418812  .022450604 .032229446  .04908463  .06767744  .09548683  .15153825 .28345758  .11342914  -1.645751
    "country1" 5 2005   .0861647     .0456177   -.24846733    -.04835508    -.005504063   .011466694  .029394565    .041956  .05216737 .073281184  .10297295  .15567893 .30322134  .09703737 -.19675295
    "country1" 5 2006  .08527346    .04259104    -.3406084    -.05515092    -.003915444     .0130605    .0257545  .03838684  .05472883  .07750607  .10679445   .1797755  .3313127   .1092799  -.7410077
    "country1" 5 2007    .106355    .04367311    -.3626013    -.05207738    -.011300126   .013037896   .02928171  .04319012  .05673432  .08139578   .1196597  .16461383  .2967354  .11696617 -1.2954075
    "country1" 5 2008  .09212613    .02960361    -.3773454    -.07981354     -.02162791   .004869143   .02218063  .03566789  .04917278   .0677662   .0999489   .1535571  .3709346  .12594992  -1.215883
    "country1" 5 2009  .09347544   .008010149     -.398222    -.10661717     -.04685502  -.017014416 .0026338855 .018173099  .03667682  .05357634  .08038546  .12665701 .26347235  .11808112  -1.311399
    "country1" 5 2010  .10045807    .04169214    -.4799534    -.06531346    -.014094308    .00976391   .02457494  .03903105  .06030878  .08278175  .11837518  .17267238  .4161286  .12917438 -1.3699483
    "country1" 5 2011  .09015185    .03793002    -.2941589     -.0796479    -.025694465   .006509672  .024154123 .034732953  .05051185 .066899925   .1060098  .15872994  .4218395  .12167666   -.177884
    "country1" 5 2012  .10405073   .020764906    -.4920145     -.1103046     -.04689472  -.006201227    .0108103  .03058775  .04557512  .06009704   .0900197  .13889624  .4213161  .13758357  -.7562149
    "country1" 5 2013  .10087954    .03914583    -.3267701    -.09223686    -.017802164    .00645366   .01980037  .03638824  .05357252  .08057185   .1113605   .1594688   .357477  .11130723  -.3299317
    "country1" 6 2002  .15551113 -.0015128036    -.9861695    -.23422626     -.09157452   -.02574774  .005648563 .030147437  .04734012  .07421834  .12450182   .2032906 .49161536   .2309334 -1.8014426
    "country1" 6 2003  .13311383    .04943813    -.7329614     -.0984272    -.035090268    .00725207  .027194576  .04690337 .070626006   .1033741   .1519632   .2361128  .5298856   .1881927 -1.1764524
    "country1" 6 2004  .14025663    .06953695    -.6089267    -.07769976    -.006876392    .02024381   .04059287  .05730909  .08751666  .12705103  .18164724   .2725083 .55344474   .1961026  -1.383877
    "country1" 6 2005  .14150476    .09015566    -.3744736    -.04474829      .00592837   .023135614   .04034172 .063757025  .09184575   .1201751   .1900424   .2795264  .5702373   .1602521  .20194773
    "country1" 6 2006  .14562097    .09568833    -.3664871    -.03781585     .002532345    .02752266   .04752464  .07262954  .10324946  .14032722  .19811156   .2920247  .5648109  .17351435 -1.1401423
    "country1" 6 2007   .1546874    .09468355    -.5731731    -.04282883      .00490917   .028524883   .05253023  .07552305  .10753161  .14285591   .1987092   .2941934  .6488358  .18190037  -.9041301
    "country1" 6 2008   .1502317    .08617527     -.384954    -.06099223    .0005512537    .02050596   .04061357  .06654939  .09683648  .13387442  .18686873  .28546742  .5735001  .15950885  -.1621773
    "country1" 6 2009  .13553189     .0643158    -.3345598    -.07823925    -.018385125   .010035722  .033229034   .0548277  .08312485   .1074566   .1629301  .24197076  .4803675   .1551005  -.5962112
    "country1" 6 2010  .14100188    .08571576    -.4162999    -.04232148    .0021689765     .0250996    .0449493  .07434507  .10315592  .13182358  .18623044  .25697127  .4720738   .1570774  -.9716018
    "country1" 6 2011  .13679317    .07770913    -.3597609    -.04709454     .003121098    .02587223    .0429403  .06884782  .09546895  .12662192  .17406613   .2428157  .4214878  .14266212 -.43358555
    "country1" 6 2012  .12152443     .0731587   -.28072646    -.06065452    .0015573872    .02034806     .041102 .062916316   .0807948  .11104132  .16682246   .2331359 .49981135  .14730342  -.4163422
    "country1" 6 2013  .13844165    .07871928    -.2737282    -.06624124     .001353807    .02341374   .04054291  .05893755  .08399507   .1149027  .17586604  .25976494 .52363825  .14493726  .27518913
    "country1" 7 2002  .02344899   .026387393   -.04817886 -.00026271402     .007709973    .01159545  .014416783 .017997421 .020438934 .026012104   .0380311 .070699014 .14753298  .03779557  1.8629453
    "country1" 7 2003  .01948738   .023362506   -.13614367   .0009207938     .007960506   .014618172  .016186593 .019683685  .02342207  .02903811 .034238007  .05958128  .1600087  .04262414  .25840795
    "country1" 7 2004 .017065156     .0296802    -.0483893    .005766061     .010783174   .015157515  .017004084 .019645166 .022225374  .02753399 .035139382  .05704641  .1922711   .0449929    1.51958
    "country1" 7 2005  .02343092   .035237115 -.0025658875    .008471952     .013370572   .016039634   .01951754  .02228422 .025355317 .033959452  .04176835  .07379334  .1860302  .04051349   2.639068
    "country1" 7 2006 .018187212   .031978723 -.0040581995     .00374377      .01145338   .014309038  .017752815 .020396894 .023468876 .029092547 .037120704  .07688147  .2059884  .03987208   2.762503
    "country1" 7 2007 .016519288    .02452854  -.003831864   .0045678653      .01013728    .01350723  .016271248  .01893144 .024106493 .027803376  .03138601  .04369557 .13928194  .02564592   2.586404
    "country1" 7 2008 .016581766    .02089577   -.05096121   -.003336258     .005423544    .01120773   .01549376 .016986404  .01945188 .022048887  .02929073  .04303933 .19630224  .03282633   3.416464
    "country1" 7 2009  .02087052   .019622535   -.09104105   -.002864744     .003614588    .01098208  .014170581 .016713979 .020361053 .024909457 .031353876  .05749472 .13501173  .03838194   .1897972
    "country1" 7 2010  .02067431    .01718142   -.08432898   -.003679725     .003956329   .007741359  .011588477 .015214113 .017895484  .02275875  .03047551  .04248103 .16457695 .033970263  1.0466878
    "country1" 7 2011 .018680075    .02132724   -.05451318  -.0015694636     .002956528  .0079174675  .010799267 .015250576 .017613191  .02114769  .02919084  .05091917 .15221746 .036750685  2.5372415
    "country1" 7 2012  .02310909   .015398523   -.11775614  -.0019766015     .003142858   .006732693  .010447594 .013900735  .01730142 .021777134 .032294918  .05517171  .1191701  .03778702  -.9736355
    "country1" 7 2013 .019181177    .02407885   -.10586757   .0006388281     .003718009   .007251433   .00879842 .012794668 .016371043 .019228047 .036122106  .06542239 .21966584  .04692483   2.026585
    "country1" 8 2002  .09758225    .04860054   -.34806165    -.03968321    -.005002063  .0010799654  .011774253  .03057411  .04954733  .08121374  .11843142  .18785445  .4016522  .12495005  -.3339961
    "country1" 8 2003  .10736115    .05905765   -.26950705    -.02626834   -.0003736748   .005211414   .02303741  .04173001  .06086683   .0918174  .13451464  .20450263 .39540935  .11651483 -.27917758
    "country1" 8 2004  .12908033    .07890072    -.2120128   -.007832929    .0006471635    .00995666   .02671138  .04862392 .073536895  .10821618  .15163314   .2266289 .56276006  .13264199   .8849259
    "country1" 8 2005  .11973336    .07477309   -.19758555   -.008265283    .0014072504   .012046594  .028032156   .0474262  .07443161    .102713    .149738  .21773097  .4119495  .12191124   .6018402
    "country1" 8 2006  .12210908    .07778075   -.25208467   -.006210989    .0015268747   .014100658  .029396104  .04973927  .07522817  .10406048   .1554419  .24320573  .4577823   .1268722  .16079146
    "country1" 8 2007  .13570377     .0935859    -.2759366   -.004323612     .003062029   .017212022   .03438036  .05734251  .08668733  .12080176  .18112764   .2659954 .54909974   .1509802   .8814493
    "country1" 8 2008  .14388527    .08281237    -.3259705    -.01483257   .00018748287   .010374612  .029125927  .04990584  .07548323  .12377079  .18082704  .26422888  .5835321  .16099136 -.08383115
    "country1" 8 2009  .11297017   .063954026    -.3390397    -.04758407   -.0007829008   .004334792   .01950402  .04041741  .06548718  .09611692  .13986124   .2269507  .4819754   .1415728   .7567139
    "country1" 8 2010  .12202451    .07672725    -.3441372    -.01897465     .001601446    .01283176  .028038885  .04413277  .06803283  .10402051   .1565497   .2470032  .5929802  .14703546   .6752805
    "country1" 8 2011   .1344569    .07926615    -.3060918    -.02501058    .0003448713   .011517095  .025222395  .04880414  .07692464  .10666019   .1651397  .24359463 .58984596  .15447646   .4033714
    "country1" 8 2012   .1229187    .07583922   -.27604997    -.03541175 -.000033627497   .011534863   .03034898   .0495019    .073038     .10432   .1569358   .2338867  .5515265  .14502345    .822567
    "country1" 8 2013  .12012394    .07395481    -.3024483    -.03034107    .0007153547   .013651394   .02566655  .04527388  .07144747  .10475671  .15856338  .23830578 .51256603  .14166538 -.09837282
    "country1" 9 2002  .09249414   .019332645    -.6245538    -.12785609    -.024545455  .0034819865   .01940565 .033172566  .04820438  .07227254  .09969687    .149458 .34599435  .14672501   -2.07964
    "country1" 9 2003  .10200325     .0517487    -.6790662    -.06198534   -.0046276283    .01488697  .031439144   .0416185  .06138353  .08557361  .12955518   .2135396  .4560108   .1549058 -1.0063652
    "country1" 9 2004   .1533213    .08252954    -.4158163    -.04906107   -.0016328752   .024324076   .03955643  .05171191  .08163448   .1199678  .19399236   .2773228   .474212  .14921325 -.04565446
    "country1" 9 2005  .14446907     .0915531   -.28905177    -.05279396     .004465094   .028686585      .04737  .06207036  .08607858   .1356438  .18808778    .298928 .55588114  .15156996   .4122129
    "country1" 9 2006  .14855357    .11205864   -.19585153   -.018297425     .015694752    .03737482   .05515214   .0713785  .10074518   .1510019   .2085725   .3294408  .6088476  .15686506   .8955406
    end
    Last edited by leon konrad; 17 Jan 2019, 08:46.

  • #2
    Welcome to Statalist and thank you for providing data. You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex. I'm having trouble understanding how you have descriptive statistics for each observation and how exactly you want to work across observations. Stata does have name functions that will generate values from a wide variety of functions - look at the documentation under functions.

    I'm afraid that your posting did not elicit a response from any of the individuals who might be sufficiently skilled in kernel related issues to help. You might try reposting with a more concise explanation of what you want to do.

    Comment


    • #3
      Alright, thanks for your response. I tried to explain the origin of the data, which is actually complicated. In any case, I only have them in this format.
      My goal is to get graphical information of a distribution over time, see example picture (different data).

      .
      Click image for larger version

Name:	example.JPG
Views:	1
Size:	25.3 KB
ID:	1480287


      My approach is to reshap the data to use normal functions like kdensity.
      Why are the distributions going up again at low and high values?
      Click image for larger version

Name:	twoway.png
Views:	2
Size:	15.6 KB
ID:	1480288


      As im using the 1% and 99% percentiles as basis of the interpolation, is there a way to get a more "normal looking" distribution?
      Its really unplausible for kdensity to estimate values above my maximum and below the minium of my data.

      I tried again without using 1% and 99% percentiles for calculation. Better but still not ideal.
      Click image for larger version

Name:	twoway2.png
Views:	1
Size:	14.8 KB
ID:	1480290


      Do you have any recommendations regarding smoothing parameters or other functions?
      Or a better way?

      Remember, my way uses only 11 (or 9) data points to create, although I also have information about Standard Deviation, Interquartile Range, Median and Skewness in my dataset.

      Code:
      /*  Information 
          each variable_p* contains information about the same indicator - just at a different positions of the underlying distribution
          p_1 = 1% percentile
          p10 = first decile
          ..
          p99 = 99% percentile    
          Given a country, sector and year, we know that only 1% of the values of the underlying distribution are smaller than variable_p1
      */
      preserve
      
      * preparing for reshape
      keep    country sector year ///
              variable_p1 variable_p10 variable_p20 variable_p30 variable_p40 variable_p50 ///
              variable_p60 variable_p70 variable_p80 variable_p90 variable_p99
              
      reshape long variable_p, i(country sector year) j(percentile)
      
      list if country=="country1" & sector==1 & year==2004
      
      /*    Thus 11 data points are available for each distribution (given country, sector, year).
              The distribution should be computed by interpolating the available moments of the distribution
              using kernal density estimation.(or else)
      */    
          
      twoway    (kdensity variable_p if country=="country1" & sector==1 & year==2004) ///
              (kdensity variable_p if country=="country1" & sector==1 & year==2009) ///    
              (kdensity variable_p if country=="country1" & sector==1 & year==2013) ,        legend(label(1 "2004") label(2 "2009") label(3 "2013"))
      
      
      
      *
      restore
      
      * again, but without lowest and highest value
      keep    country sector year ///
              variable_p10 variable_p20 variable_p30 variable_p40 variable_p50 ///
              variable_p60 variable_p70 variable_p80 variable_p90
      
      reshape long variable_p, i(country sector year) j(percentile)
      
      twoway    (kdensity variable_p if country=="country1" & sector==1 & year==2004) ///
              (kdensity variable_p if country=="country1" & sector==1 & year==2009) ///    
              (kdensity variable_p if country=="country1" & sector==1 & year==2013) ,        legend(label(1 "2004") label(2 "2009") label(3 "2013"))



      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str13 country byte sector int year float(variable_iqr variable_mean variable_p1 variable_p10 variable_p20 variable_p30 variable_p40 variable_p50 variable_p60 variable_p70 variable_p80 variable_p90 variable_p99 variable_sd variable_skew)
      "country1" 1 2002 .08316796 .04337303  -.2269545   -.0532232  -.011277346 .010716712  .02375466  .03676545 .05130272  .07306185   .100204 .15511613 .3231776 .09509224  .10951895
      "country1" 1 2003 .08760485 .04784622   -.238902  -.05387203  -.006918778 .012898994 .026654657  .04035446   .055961   .0764264 .11114395 .16308586 .3396377 .09903994  -.1742165
      "country1" 1 2004 .09420463 .05783209  -.2124942  -.04086492 .00027718392  .01729789 .031905305  .04634453 .06357674  .08829361 .12173408 .18030873 .3410014  .0994368   .2256225
      "country1" 1 2005 .09012224 .05646351 -.20423368  -.03779425 -.0001217368  .01812411  .03113085   .0444632 .05982694   .0839219 .11683664  .1784417 .3368082 .09902152  .18024056
      "country1" 1 2006 .09225135 .06384529 -.20904528 -.029345926   .005902195 .022295317 .036943417  .05125748 .06885449   .0929598 .12435046  .1867929 .3494133 .10115737  .08973073
      "country1" 1 2007  .0944089 .07030966   -.200514  -.02299091    .01086669  .02682073  .04079077  .05686638  .0752304  .09839115 .13225667 .19800973 .3731743 .10323163   .1156162
      "country1" 1 2008 .08910593 .05157742 -.21418253   -.0472291 -.0039400365 .014217508  .02860503  .04301681 .05936781  .08179826 .11261054  .1664505 .3475431 .10136232 .017438319
      "country1" 1 2009 .08879016 .03437477 -.29379678  -.08138897  -.023671916 .004407109  .02002304 .033010032 .04734708   .0693822 .10187984  .1594217 .3151034 .10845645  -.4760354
      "country1" 1 2010  .0844996 .04771335 -.24874413  -.05143419  -.003691586 .013759927 .025977327   .0409242 .05654737   .0774783 .10947449 .16915904 .3276501  .1016138 -.16067374
      "country1" 1 2011 .08636101 .04614235  -.2490693  -.05100594  -.005127077 .012980284 .025043065  .03815276 .05374928   .0765989  .1099275 .16314936 .3277772 .10166649  -.6308886
      "country1" 1 2012 .08054356 .03675485 -.28166053  -.06294364  -.013115568 .008894721  .02022787  .03260161 .04678672  .06719011 .09600998 .14604461 .3096482 .10228572  -.8992358
      "country1" 1 2013 .08239385 .03785191  -.2814472  -.06107039  -.010723745  .00920183 .021132715 .033136528 .04934089 .070009016 .10093711  .1498375 .3013457 .10366511  -1.341187
      end



      Attached Files

      Comment

      Working...
      X