Announcement

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

  • Chart for panel data

    Hi Statalists,

    Is there any way to create a chart as the following:
    Click image for larger version

Name:	Schermata 2022-01-05 alle 10.33.20.png
Views:	1
Size:	844.0 KB
ID:	1643659

    Last edited by Alessandro Franconi; 05 Jan 2022, 04:18.

  • #2
    You would need a combination of twoway area and twoway rarea

    Comment


    • #3
      Thanks Nick.

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input float date long category float(equity_l housing_l other_l)
      118 1  68476 1980246 286120.06
      119 1  74057 1962616 292521.06
      120 1  75334 2028664 297460.06
      121 1  78738 2010220 302436.06
      122 1  77914 2116272 309116.06
      123 1  81946 2148219  313580.1
      124 1  86265 2175970  317124.1
      125 1  89862 2230094  318433.1
      126 1  92006 2317623  321305.1
      127 1  96071 2407047  322258.1
      128 1  95918 2408873  319762.1
      129 1  98678 2406925  322367.1
      130 1 100006 2555396  325237.1
      131 1 103823 2613035  322900.1
      132 1 104412 2506511  317066.1
      133 1 106019 2612624  314622.1
      134 1 109006 2730430  313045.1
      135 1 111528 2792637 311561.06
      136 1 110540 2767628  308152.1
      137 1 111610 2815958  308924.1
      138 1 115238 2917941  309709.1
      139 1 116923 2950516  311555.1
      140 1 120343 3012481  312002.1
      141 1 124852 3241384  312273.1
      142 1 130071 3415028 309432.06
      143 1 134060 3421745  315135.1
      144 1 137560 3427100  321347.1
      145 1 140589 3423155  325099.1
      146 1 140386 3422564  332368.1
      147 1 141745 3369064  336666.1
      148 1 153604 3365256  338974.1
      149 1 161555 3402029  343486.1
      150 1 171034 3483742  349094.1
      151 1 179672 3441197  358696.1
      152 1 196276 3495416  359132.1
      153 1 201232 3472438  362878.1
      154 1 199099 3625744  367810.1
      155 1 209331 3597807  378930.1
      156 1 205873 3708175  377765.1
      157 1 208054 3754836  374090.1
      158 1 205252 3900936  384232.1
      159 1 220683 3922227  405800.1
      160 1 220089 4033328  397345.1
      161 1 212422 4097527  398791.1
      162 1 217896 4276387  408976.1
      163 1 206266 4283806  423877.1
      164 1 190113 4305839  435665.1
      165 1 192573 4434253  431160.1
      166 1 177584 4597517  439865.1
      167 1 180751 4598215  446672.1
      168 1 177543 4585313  436540.1
      169 1 165683 4621815  408704.1
      170 1 148396 4820652  413485.1
      171 1 180530 4935647  418818.1
      172 1 177667 4895718  413902.1
      173 1 181728 4922450  405235.1
      174 1 175812 5073476  394270.1
      175 1 174698 5327445  397255.1
      176 1 176208 5311037  394021.1
      177 1 169843 5566972  384575.1
      178 1 167455 5781062  377081.1
      179 1 171165 5991902  402868.1
      180 1 169130 6170423  404999.1
      181 1 172295 6394250  416398.1
      182 1 177299 6723243  426548.1
      183 1 184536 6983586  447039.1
      184 1 202732 7200835  452159.1
      185 1 215023 7404845  453408.1
      186 1 227549 7627342  474311.1
      187 1 238107 7836270  498108.1
      188 1 256518 7964666  502264.1
      189 1 279057 8061047  500006.1
      190 1 297751 8056969  515423.1
      191 1 299762 8016494 530687.06
      192 1 296250 8083218  509896.1
      193 1 294932 7937659  481179.1
      194 1 296360 7621988  470634.1
      195 1 281702 7531865  518003.1
      196 1 272617 7663960  487673.1
      197 1 265395 7437205  491738.1
      198 1 263529 7207213  460669.1
      199 1 261581 7077523  509713.1
      200 1 257606 6920015  463912.1
      201 1 252875 6777692  448593.1
      202 1 254263 6901789  446643.1
      203 1 253762 6793958  493558.1
      204 1 254373 6537331  482697.1
      205 1 248003 6277757  495130.1
      206 1 224262 6457388  500081.1
      207 1 226133 6483686 547458.06
      208 1 237811 6300410 540108.06
      209 1 231924 6227986 530530.06
      210 1 235554 6317503 554020.06
      211 1 234146 6344962 576335.06
      212 1 241967 6222412 584021.06
      213 1 242448 6278717 569294.06
      214 1 247675 6388022 599705.06
      215 1 249429 6368995  626830.1
      216 1 250591 6302270 621983.06
      217 1 260383 6416843  630412.1
      end
      format %tq date
      label values category category_temporary
      label def category_temporary 1 "Bottom50", modify
      For now I have the following:

      Code:
      twoway area equity_l date || rarea equity_l housing_l date || rarea housing_l other_l date, by(country, note(""))
      How can I have a different y-axis for each group?
      Last edited by Alessandro Franconi; 05 Jan 2022, 08:39.

      Comment


      • #4
        That is unlikely to be what you need. I imagine you need to start


        Code:
        gen plot2 = equity + housing 
        gen plot3 = plot2 + others 
        
        twoway area equity date || rarea plot2 equity date || rarea plot3 plot2 date

        Comment


        • #5
          I need to cumulate, right!

          Comment


          • #6
            But How can I have a different y-axis for each group?

            Comment


            • #7
              I am not an economist but I find the plots in #1 the wrong way round. I would want to start with

              total assets

              total debts

              with bottom 50% compared with the other groups on the same scale.

              Then there might be scope for looking at components of assets and debts.

              Those in #1 show (to this non-economist) unsurprising growth overall with an unsurprising disturbance around 2008-2009. The use of different scales makes many interesting comparisons harder!

              As with related threads on transformations showing small and large negative and positive together on the same graphs might need some ingenuity.

              All depends what you want to show (most). #1 presumably from someone else is a good example of a design that is fairly easy to understand in principle but hard to work with in practice.

              Comment


              • #8
                Fair point and I agree with you. However, if you look at the y-axis, it is straightforward to realize that keeping the same scale would mean having a line for the Bottom 50% and 50-90% groups. In my case, I further disaggregate top10% between top1% and 10-1% group, hence keeping the same y-axis makes only the Bottom50% less detailed...

                p.s. the aim there is not to compare assets between groups but to show the composition among groups, that is why I believe they set different scales.

                Comment

                Working...
                X