Announcement

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

  • How to get a xtline graph of averages of variable

    Dear stata users,

    I have panel data for 32 countries from 1990-2012.

    I want to create a graph which shows the evolution of a variable for a specific set of countries and the average. In my case it is about green house gas emissions (GHG).
    So, basically I want 3 lines:
    - The evolution of GHG for all OECD countries together over the years
    - The evolution of GHG for all BRICS countries together over the years
    - The evolution of GHG for all countries total over the years

    I tried the command below, which will give me a graph of the briics countries (Brazil (4), russia (24), etc), but all seperate lines. Is there a way to make an average out of these countries into one line?

    Do I have to make a new variable? If so, how?

    Or is there a command I can use to create the graph I want.

    Code:
    xtline GHG if inlist(countryid, 4, 24, 14, 15, 6, 26), overlay
    Thank you in advance!

  • #2
    xtline is really to designed to show separate panels separately, and not much else. It's a convenience graphing command rather than a calculation tool.

    However, as documented you can use the addplot() option to superimpose graphs of other variables, which must be calculated beforehand.

    If I understand correctly totals will make more sense than averages here.

    EIther way, it is often simplest to calculate directly what you want to show and then call up line. egen can be very helpful there.

    Comment

    Working...
    X