+ Reply to Thread
Results 1 to 4 of 4

Thread: Graph # Dummy variables

  1. #1
    Points: 77, Level: 1
    Level completed: 54%, Points required for next Level: 23

    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Graph # Dummy variables



    Dear all,

    I am new to both this forum as to Stata.
    I have a question regarding how to graph dummy variables.

    I have a dataset consisting of different firms and different firm years. I have two dummy variables namely 1 for divestititures (dumdiv) and 1 for acquisitions (dumacq)

    I want to graph the frequency of the amount of dummy=1 , per year.
    this is how the tabulate version looks (of 1 variable)

    dumdiv
    Year 0 1 Total

    1992 1,002 92 1,094
    1993 1,051 115 1,166
    1994 1,076 110 1,186
    1995 1,134 138 1,272
    1996 1,160 155 1,315
    1997 1,208 152 1,360
    1998 1,230 187 1,417
    1999 1,278 166 1,444
    2000 1,455 176 1,631
    2001 1,556 172 1,728
    2002 1,556 182 1,738
    2003 1,602 196 1,798
    2004 1,593 197 1,790
    2005 1,543 225 1,768
    2006 1,492 228 1,720
    2007 1,442 214 1,656
    2008 1,487 164 1,651
    2009 1,497 136 1,633
    2010 1,434 148 1,582
    2011 1,271 119 1,390

    Total 27,067 3,272 30,339

    so i want to graph the 3th column with the first one. and the same for acquisitions. (both in one graph)


    Thank you very much!

  2. #2
    RoboStataRaptor
    Points: 7,301, Level: 56
    Level completed: 76%, Points required for next Level: 49
    bukharin's Avatar
    Location
    Sydney, Australia
    Posts
    1,015
    Thanks
    9
    Thanked 240 Times in 233 Posts

    Re: Graph # Dummy variables

    What kind of graph do you want (bar, scatterplot, line graph...)?

    A bar graph is easiest because the frequency of the dummy==1 is equal to the sum of the dummy variables:
    graph bar (sum) dumdiv, over(Year)

    If you want to use a -twoway- plot type (such as a line graph) you're best to collapse the dataset into the table that you posted:
    collapse (sum) dumdiv, by(Year)
    line dumdiv Year

    If you want to create the graph without destroying your original data you can use -preserve-, like this:
    preserve
    collapse (sum) dumdiv, by(Year)
    line dumdiv Year
    restore

  3. #3
    Points: 77, Level: 1
    Level completed: 54%, Points required for next Level: 23

    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Graph # Dummy variables

    Perfect Bukharin, thank you, it works! But how do I do the same if i want just one graph with both my divestitures and Acquisitions?

  4. #4
    RoboStataRaptor
    Points: 7,301, Level: 56
    Level completed: 76%, Points required for next Level: 49
    bukharin's Avatar
    Location
    Sydney, Australia
    Posts
    1,015
    Thanks
    9
    Thanked 240 Times in 233 Posts

    Re: Graph # Dummy variables


    It's pretty much a simple extension of the above, eg:
    graph bar (sum) dumdiv dumacq, over(Year)

    or

    preserve
    collapse (sum) dumdiv dumacq, by(Year)
    line dumdiv dumacq Year
    restore

  5. The Following User Says Thank You to bukharin For This Useful Post:

    oseroser (10-24-2012)

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats