Announcement

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

  • Graph for Panel Data

    Hi Statalist,

    I cannot find the right code for the kind of graphs I would like to produce and was wondering if you could help!

    I have panel data. There are ten countries in my dataset. The variables are called year countryid, year, tax, law, and fdi.

    1) For each country I would like to show in an extra diagram how tax, law, and fdi developed over time (hence, 10 diagrams with each three curves).

    2) For all countries I would like to show in one single diagram how fdi developed over time (hence, 10 curves in one diagram).

    How do I go about this? I have tried a few things, but none worked.

    Best,
    Lucas


  • #2
    You need to use the -by()- option for your first set of graphs:

    Code:
    sort year
    twoway line tax law fid year, by(countryid)
    One easy way to accomplish your second graph is to separate fdi by country with the separate command (see the help file for labeling options)
    Code:
    separate fdi, by(countryid) gen(_fdi_)
    sort year
    twoway line _fdi_* year
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      Great, thanks a lot!

      Comment


      • #4
        Hi,
        Can anyone help me to know how to make a stacked bar chart and a curve at the same time?

        Thanks,

        Comment


        • #5
          That can only be done with
          Code:
          twoway rbar
          and

          Code:
          line
          Last edited by Nick Cox; 12 Jun 2020, 05:59.

          Comment

          Working...
          X