Announcement

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

  • Making graph more organized

    Hello, everyone. I am new to Stata. I am so sorry for my fundamental question. I composed a graph related to “coefplot” using the following command with sample data(nlsw88.dta).



    sysuse nlsw88 dta, clear
    reg wage i.race i.union if industry == 4
    estimates store A
    reg wage i.race i.union if industry == 6
    estimates store B
    reg wage i.race i.union if industry == 7
    estimates store C
    reg wage i.race i.union if industry == 11
    estimates store D
    reg wage i.race i.union if industry == 12
    estimates store E
    coefplot (A) || (B) || (C) || (D) || (E) ||, keep(2.race 3.race) vertical yline(0)


    I would like to make this more organized due to a constraint on space. Does anyone know how to combine A, B, C, D, and E into one table? In case anyone asked before, kindly let me know the URL.


    Thank you very much for your support.

  • #2
    Thanks for the reproducible example. coefplot is from SSC (FAQ Advice #12). Here is some technique:

    Code:
    sysuse nlsw88, clear
    reg wage i.race i.union if industry == 4
    estimates store A
    reg wage i.race i.union if industry == 6
    estimates store B
    reg wage i.race i.union if industry == 7
    estimates store C
    reg wage i.race i.union if industry == 11
    estimates store D
    reg wage i.race i.union if industry == 12
    estimates store E
    
    coefplot (A B C D E, keep(2.race) label("Black"))  ///
    (A B C D E, keep(3.race) label("Other")), ///  
    aseq swapname ylab(, noticks)
    Res.:
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	30.8 KB
ID:	1777027

    Last edited by Andrew Musau; 07 May 2025, 05:31.

    Comment


    • #3
      Or if you prefer vertical CIs:

      Code:
      coefplot (A B C D E, keep(2.race) label("Black"))  ///
      (A B C D E, keep(3.race) label("Other")), ///  
      aseq swapname xlab(, noticks) ylab(, grid) vert

      Click image for larger version

Name:	Graph.png
Views:	1
Size:	28.1 KB
ID:	1777029

      Comment


      • #4
        Thank you very much. You helped me a lot. This was exactly the table I wanted to compose.

        There are two more things I could use your help with if that’s okay.
        One is about the arrangement of the same two tables, with different dependent variables, either vertically or horizontally in one table. Here is the second table I want to add.

        reg tenure i.race i.union if industry == 4
        estimates store F
        reg tenure i.race i.union if industry == 6
        estimates store G
        reg tenure i.race i.union if industry == 7
        estimates store H
        reg tenure i.race i.union if industry == 11
        estimates store I
        reg tenure i.race i.union if industry == 12
        estimates store J

        I read through “A Visual Guide to Stata Graphics,” however, I could not find a way to have two tables with different dependent variables in one table.

        Also, is there a way to change one of the lines including the dot to a different shape without changing the other since I will be using monochrome print and the color maroon or blue distinguishable?

        The book I read explains the command “msize(huge),” but it does not look very attractive so I am looking for a different way.


        Thank you very much for your help.


        Comment


        • #5
          For Stata graphics, I would recommend Speaking Stata Graphics; it provides a more practical understanding of how to create and customize graphs effectively.

          Code:
          sysuse nlsw88, clear
          reg wage i.race i.union if industry == 4
          estimates store A
          reg wage i.race i.union if industry == 6
          estimates store B
          reg wage i.race i.union if industry == 7
          estimates store C
          reg wage i.race i.union if industry == 11
          estimates store D
          reg wage i.race i.union if industry == 12
          estimates store E
          reg tenure i.race i.union if industry == 4
          estimates store F
          reg tenure i.race i.union if industry == 6
          estimates store G
          reg tenure i.race i.union if industry == 7
          estimates store H
          reg tenure i.race i.union if industry == 11
          estimates store I
          reg tenure i.race i.union if industry == 12
          estimates store J
          
          coefplot (A B C D E F G H I J, keep(2.race) label(Black) ms(Sh) ciopts(lp(dash))) ///
          (A B C D E F G H I J, keep(3.race) label(Other) ms(Oh)), ///
          aseq swapname ylab(, noticks) ///
          groups(A B C D E= "Wage" F G H I J= "Tenure") ///
          scheme(stmono2)
          Click image for larger version

Name:	Graph.png
Views:	1
Size:	41.0 KB
ID:	1777075

          Last edited by Andrew Musau; 08 May 2025, 06:24.

          Comment


          • #6
            You should probably also sort the models within groups (depending on the coefficient value), as the model names are most likely arbitrary. This results in a graph that is easier to read.

            Comment


            • #7
              It is so kind of you. This was precisely the table I wanted to compose. I cannot thank you enough.

              The book you recommended seems so insightful to learn from so I'll make sure to get it.

              I have decided to pursue composing more visualized graphs and tables by making use of this opportunity from now on.

              Thank you very much for your help.

              Comment

              Working...
              X