Announcement

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

  • Stata Legend Not Working

    I am running a model with interactions, and I am trying to plot the interaction plot; however, the legend is being weird leaving off one symbol. Does anyone know what is going on? Not only is there no symbol for the 0 Count group, all of the other colors don't map to the correct group. I don't want to use the graph editor because I need to create many similar graphs, so I would like to be able to code it directly. Appreciate the help.

    Picture1.jpgPicture2.jpg



    Variable Definitions:
    Bill: Continuous (0,650)
    Treatment: Binary 0,1
    Count: Counting the frequency of something occurring (0,1,2,3+)
    Time: Continuous (0,500)

    Code:
     tpm bill i.treatment i.treatment##i.count  i.treatment##c.time, f(logit) s(glm,family(gamma) link(log)) 
    
    margins, at(time=(0(50)500) count=(0 1 2 3) treatment=(0))
    
    marginsplot, noci title("Control Group: Time Variable and Count Variable") xtitle("Time (weeks)", margin(medium)) ytitle("Bill", margin(medium)) graphregion(col(white)) ylabel(0(200)600, labsize(small)) xlabel(0(100)500, labsize(small)) 
    
    marginsplot, noci title("Control Group: Time Variable and Count Variable") xtitle("Time (weeks)", margin(medium)) ytitle("Bill", margin(medium)) graphregion(col(white)) ylabel(0(200)600, labsize(small)) xlabel(0(100)500, labsize(small)) legend(on order(0 " 0 Count" 1 "1 Count" 2 "2 Count" 3 "3+ Counts"))

  • #2
    The numbers specified within -order()- do not conform to values of some variable, but are integers starting with 1, where "1" represents the first plot, "2", the second plot and so on. So this is a misunderstanding on your part.

    Comment


    • #3
      Appreciate the input Andrew Musau, but I'm not sure I follow. From the first graph, you can see the values for the count variable in the legend are 0, 1, 2, and 3, which is what I have specified in the legend statement.

      Comment


      • #4
        And that is exactly what Andew said you should not do. The numbers you specify in the order() option should not be the value, but just 1 for the first plot, 2 for the second plot, etc.
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Thank you, gentlemen! I understand and that worked.

          Comment

          Working...
          X