Announcement

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

  • Panel data line plots - overlayed graph for smaller selection

    Dear stata users,

    I have panel data for 32 countries for 22 years. I want an overlayed graph of only 6 countries using xtline, overlay, but I can't seem to get just this small selection of countries. When I use this command I can only get 1 country (xtline espi if countryid==4 (for example) or all 32. How can I include more countries?

    Thank you in advance!

  • #2
    Code:
    if inlist(countryid, 2, 3, 5, 7, 11, 13)

    Comment


    • #3
      you didn't provide a data example (use -dataex- and post within CODE blocks) but here is a guess (but you will have to replace the countryid's with the numbers you want):
      Code:
      xtline espi if inlist(countryid,4,5,7,9,12,24), overlay

      Comment


      • #4
        Originally posted by Rich Goldstein View Post
        you didn't provide a data example (use -dataex- and post within CODE blocks) but here is a guess (but you will have to replace the countryid's with the numbers you want):
        Code:
        xtline espi if inlist(countryid,4,5,7,9,12,24), overlay
        This worked! Thank you.

        The countries I wanted to have seperately are the briics countries. Do you know if it is also possible to plot a graph with the average of these countries?
        So in short, I would like to have 1 graph with 3 lines; the average of country selection 1, the average of country selection 2, and the total combined.
        Could you help me with this?

        Comment


        • #5
          please read the FAQ and provide a data example using -dataex- and posting the result within CODE block

          Comment


          • #6
            Originally posted by Rich Goldstein View Post
            please read the FAQ and provide a data example using -dataex- and posting the result within CODE block
            Code:
            * Example generated by -dataex-. To install: ssc install dataex
            clear
            input str15 country int year float espi long ghg float(upmillion ip gdp ec popmillion ei countryid)
            "Brazil"       1996  .42  262900 128.89 22.34   2.21  1687.09  163.76      2  4
            "Brazil"       2011  .38  417120 167.15  23.1   3.97   2430.8   196.6  72.93  4
            "Brazil"       1995  .42  241500 125.74 23.38   4.22   1634.4  161.34   1.75  4
            "Brazil"       1997  .42  281510 132.17 22.59   3.39  1762.41  166.18      5  4
            "Brazil"       1998  .42  290760 135.45 22.12    .34  1808.34   168.6   6.83  4
            "Brazil"       2009  .42  350830 162.94 21.88   -.13  2197.13  192.98  52.88  4
            "Brazil"       2004  .42  326760 151.84 24.31   5.76  1956.16  182.86   25.5  4
            "Brazil"       2000  .42  312670 141.91 23.01   4.39  1897.35  173.76  11.33  4
            "Brazil"       2010  .42  397730 165.05 23.27   7.53  2374.12  194.89  76.47  4
            "Brazil"       2008  .42  372160 160.82 23.09   5.09  2229.85  191.01  65.21  4
            "Brazil"       2007  .42  351520 158.66 23.13   6.07  2167.61  189.03  69.08  4
            "Brazil"       2002  .63  317280    147  22.5   3.05  1806.67  178.49   9.83  4
            "Brazil"       2005  .42  330510 154.17 24.17    3.2   2015.8  184.99  28.44  4
            "Brazil"       2012  .38  451760 169.24 22.13   1.92  2501.47  198.31  67.75  4
            "Brazil"       2003  .58  309350 149.45 23.08   1.14  1882.26   180.7  24.56  4
            "Brazil"       2006  .42  333980 156.44 23.54   3.96  2072.36  187.06  62.99  4
            "Brazil"       2001  .54  319560  144.5 22.64   1.39  1747.94   176.2  11.58  4
            "Brazil"       1999  .42  300620  138.7 21.75    .47  1832.38  171.02  11.75  4
            "India"        1993   .4  652470 242.89 26.78   4.75   320.55   927.4    .33 14
            "India"        2010  1.2 1665310 381.76 30.73    8.5   640.39 1234.28 202.34 14
            "India"        2009 1.13 1568530 372.46 31.12   7.86    598.5 1217.72 140.45 14
            "India"        1995  .46  741100 256.47  28.6   7.57   358.76  963.92    .33 14
            "India"        1998  .46  839830  277.7  27.3   6.18   385.86 1019.48   1.42 14
            "India"        2002   .6  987530 308.79 27.66    3.8   410.64 1093.31   42.5 14
            "India"        1997  .46  821480 270.52 27.84   4.05   375.49  1000.9    .25 14
            "India"        2006  .67 1214250 344.62 30.93   8.06   509.21 1165.48  64.11 14
            "India"        1991   .4  607340 229.75 26.44   1.06    290.9  891.27      1 14
            "India"        2004   .6 1087190 326.49 29.22   7.92   451.61 1129.62  38.61 14
            "India"        2001  .56  953880 300.11 26.49   4.82   393.81    1075  17.94 14
            "India"        2000  .56  940170 292.32 27.33   3.84   393.65 1056.57   8.03 14
            "India"        1999  .46  904090 284.97 26.52   8.85   392.04 1038.05  10.33 14
            "India"        2008  .63 1423880 363.15 31.14   3.09   561.25 1200.66 111.55 14
            "India"        1994   .4  687950 249.62 27.63   6.66   341.23   945.6     .5 14
            "India"        1996  .46  776720 263.44 27.91   7.55   359.82  982.36   3.42 14
            "India"        2005  .67 1137740  335.5 29.53   7.92   468.03  1147.6  54.04 14
            "India"        2012  1.3 1908570 400.41  29.4   5.46   723.24 1265.78  198.2 14
            "India"        2011 1.26 1760800 391.04 30.16   5.24   696.84 1250.28 209.81 14
            "India"        2003   .6 1015890 317.58 27.47   7.86   430.48 1111.52  53.81 14
            "India"        2007  .63 1336100 353.85  30.9   7.66   541.74  1183.2  84.21 14
            "Indonesia"    2012 1.17  486750 127.39 43.59   4.61   733.37  248.45   1.53 15
            "Indonesia"    2002  .44  306060  94.69 47.75   3.09    417.5  217.35      1 15
            "Indonesia"    1996  .44  234480  74.43 43.46   6.22    297.2   199.9    .33 15
            "Indonesia"    2007   .5  379980 110.45  46.8   4.95   546.15  232.37      4 15
            "Indonesia"    1998  .44  261140  81.45 45.23 -14.35   331.11  205.72    .33 15
            "Indonesia"    2005  .44  344400 103.96 46.54   4.29   500.65  226.28    1.1 15
            "Indonesia"    2009   .5  394490 117.24 47.65   3.25   593.94  238.62      2 15
            "Indonesia"    2010 1.17  416940  120.7 42.78   4.81   635.99  241.83   2.42 15
            "Indonesia"    2004  .44  343160 100.81 44.63   3.63   474.37  223.28      3 15
            "Indonesia"    2011 1.17  480460 124.01 43.91   4.75   680.28  245.11   2.07 15
            "Indonesia"    2006   .5  364100 107.17 46.94   4.11   516.03  229.31    4.5 15
            "Indonesia"    2000  .44  280170  88.84 41.97   3.48   390.42  211.51      5 15
            "South Africa" 2004  .44  379970  27.89  26.3   4.55  4589.91   47.37  36.17 26
            "South Africa" 2003  .44  353110   27.3 26.89   2.95  4559.77   46.86  33.75 26
            "South Africa" 1997  .48  288920  23.83 29.25    2.6   4818.5   42.98     25 26
            "South Africa" 1994  .48  252010   21.9 31.23    3.2  4068.48   40.56      5 26
            "South Africa" 1998  .52  296510  24.43 28.58     .5   4606.9   43.68   25.4 26
            "South Africa" 2005   .4  377640   28.5 26.02   5.28  4636.93   47.92   52.5 26
            "South Africa" 2000  .44  284730  25.58 28.23    4.2  4579.95   44.96  36.75 26
            "South Africa" 2001  .44  320600  26.14 28.53    2.7  4302.12   45.57  48.25 26
            "South Africa" 2011 1.71  409120  32.63 24.84   3.17  4566.32   52.01  42.68 26
            "South Africa" 1995  .48  264190  22.57 30.98    3.1  4157.57   41.43   7.75 26
            "South Africa" 1999  .48  278470  25.01 27.67    2.4  4470.96   44.33  39.15 26
            "South Africa" 2009 1.52  404020  31.13 25.74  -1.54  4428.15   50.46  36.33 26
            "South Africa" 2006  .52  379560  29.13 24.86    5.6  4721.93   48.48  38.53 26
            "South Africa" 1991  .44  242330  19.82  35.1  -1.02  4128.27   37.71   1.67 26
            "South Africa" 1996  .48  273980  23.21 29.89    4.3  4705.95   42.24  13.62 26
            "South Africa" 2002  .44  331420  26.72 28.51    3.7  4528.82    46.4  49.64 26
            "South Africa" 1993  .48  246430  21.21 31.93   1.23  4023.29   39.63      4 26
            "South Africa" 2007  .52  396900  29.77 25.29   5.36  4851.69   49.09  38.42 26
            "South Africa" 2012  .71  426710  33.42 24.47    2.4  4366.03   52.82   36.2 26
            "South Africa" 2008  .48  426560  30.44 26.94   3.19  4665.18   49.75  48.89 26
            "South Africa" 2010 1.75  425110  31.86  25.3   3.04   4542.6   51.22  45.08 26
            "South Africa" 1992  .48  238820  20.51 33.68  -2.14  3997.04   38.67      1 26
            "Australia "   1997  .46  306770  15.67 25.22   3.91  9291.08   18.42  89.77  1
            "Australia "   1995   .5  289010  15.34 26.43   3.83  8994.36      18   85.8  1
            "Australia "   2002 1.21  352890  16.55 23.64   4.01 10813.12   19.49 164.03  1
            "Australia "   2000  .98  338810  16.13 24.59   3.91 10193.91   19.02 136.86  1
            "Australia "   1996  .46  299590  15.52 25.98   3.85   9108.3   18.22  70.05  1
            "Australia "   2003 1.21  351990  16.78 24.06   3.11 10434.87   19.72 165.63  1
            "Australia "   2005 1.55  369510  17.25 24.64   3.16 10458.45   20.17 193.38  1
            "Australia "   1999 1.02  333040  15.96 24.63   4.94 10036.46   18.81 128.07  1
            "Australia "   1992   .5  268360  14.92 26.87    .41  8550.33   17.47   76.5  1
            "Australia "   2007 2.01  385370  17.66  25.7   3.77 10972.89   20.82 211.84  1
            "Australia "   2004 1.17  365270     17 23.95   4.21 10554.82   19.93 205.77  1
            "Australia "   2001 1.09  344960  16.32 23.67   2.04 10636.38   19.27 148.93  1
            "Australia "   2012 3.72  385770  19.41 26.39   3.92 10407.74   22.73 194.63  1
            "Australia "   2008 2.26  388500  18.04 25.63   3.58 10749.11   21.24 210.31  1
            "Australia "   1998  .77  327660  15.81 25.38   4.61  9783.44    18.6 110.02  1
            "Australia "   2011 3.34  385770  19.05 26.53   2.47 10627.29   22.34 222.21  1
            "Australia "   1990   .5  263600  14.57 28.78   3.57  8527.23   17.06  44.92  1
            "Australia "   1993  .75  272360  15.04 26.82   4.03  8701.76   17.63  86.01  1
            "Australia "   1991   .5  264710  14.76 27.66    -.4  8522.16   17.28   68.4  1
            "Australia "   2010  2.5  387350  18.76  25.2   2.17 10726.93   22.03 240.31  1
            "Australia "   1994   .5  278670  15.18 26.78   3.98  8812.49    17.8  76.63  1
            "Australia "   2009 2.69  394950  18.45 27.07   1.87 10791.59   21.69 224.88  1
            "Australia "   2006 2.01  375060  17.53 25.64   2.73 10490.48   20.45 193.77  1
            "Austria"      2003 2.48   74460   4.82  27.5    .94  7695.08    8.11  68.37  2
            "Austria"      2000 2.02   63530   4.82 28.28   3.38  7076.27    8.01  91.22  2
            "Austria"      2012 2.95   65110   4.81 25.63    .68  8548.88    8.42 217.16  2
            "Austria"      1991 1.42   62420   4.86 29.51   3.44  6347.22    7.75  32.08  2
            end

            Comment

            Working...
            X