Announcement

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

  • Grouped bar chart by dummies and with time as x-axis

    Dear All,

    I have panel data on firms. I want to show on my bar chart how the revenue evolved over time for two groups:
    1. important firms
    2. important firms + polish firms

    I have dummy imp=1 if a firm is important and imp_polish=1 if a firm is important or is polish.

    Now I want to visualize on the bar chart how the revenue of two groups evolved over time. I'm only interested in the case when the dummies for both equaled 1. I tried graph twoway bar revenue time, over(imp) over(imp_polish). I saw that the option over() was not allowed + I don't know how to tell stata to take only into consideration those groups when dummy is equal 1.

    Please help me. I literally got stuck with it

  • #2
    I would advise against using "over" on a bar chart, as it would just lead to a walls of bars covering each other. If bar chart is a must, then use by() to panel them:

    Code:
    sysuse nlsw88, clear
    
    collapse (mean) wage, by(married union age)
    drop if union == .
    
    twoway bar wage age, by(union married)
    If overlapping is the primary visual goal, then use a multi-layered line chart:

    Code:
    sysuse nlsw88, clear
    
    collapse (mean) wage, by(married union age)
    drop if union == .
    
    twoway line wage age if married == 0 & union == 0 || ///
           line wage age if married == 0 & union == 1 || ///
           line wage age if married == 1 & union == 0 || ///
           line wage age if married == 1 & union == 1, ///
           legend(label(1 "Unmarried, non-union") ///
                  label(2 "Unmarried, union") ///
                  label(3 "Married, non-union") ///
                  label(4 "Married, union"))

    Comment


    • #3
      Thank you for your answer Ken. The second code is closer to what I want to obtain. Howver, I would like to have a bar chart. Is there a possibility to change the type of chart when edditing?
      I also tried a code:
      Code:
      twoway bar revenue time if imp==1 || bar reveneu time if imp_polish==1,
      legend(label(1, "important firms") label(2, "important firms + polish firms"))
      I didn't get what I wanted though

      Comment


      • #4
        Nobody can help me?

        Comment


        • #5
          I doubt that #3 is clear to anyone except yourself. You don't give example data, you don't show the graph you got, and the problem reported is that you didn't get what you wanted.

          You would have got an error message unless you have different variables revenue and reveneu

          The commas in the legend() call are non-standard but not illegal.

          Comment


          • #6
            I'm sorry. I didn't know it might be confusing. I will try to generate a fake data example

            Comment

            Working...
            X