Announcement

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

  • Marginsplot command sub-option showing error

    Dear all,

    Below my codes for margins plot which is throwing up error message. The 'marginsplot' works fine when I am using the 'by' option alone. Whenever any sub-option with 'by' is added, the error message plays the role. I am sure it is a valid command for 'twoway graph' options and used it several times. Not sure why it is not working with marginsplot:


    Code:
    margins i.sex, at(lmg=(15(10)65)agecen=(-4.4 -1.4 1.5 4.5))
    
     marginsplot, xdim(lmg) by(sex, title("My title"))
    
    option title() not allowed
    Is the sub-options followed by 'by' not allowed with 'marginsplot' ? I would not assume so.

    Stata version: 14.1, OS: Mac 64-bit
    Updated as of today.
    Last edited by Roman Mostazir; 02 Apr 2016, 19:07. Reason: Added Stata version
    Roman

  • #2
    Running the following command will probably do a better job at explaining than my attempt with words. I find the byopts title a little counter intuitive in by graphs.

    Code:
    marginsplot, xdim(lmg) by(sex) title("title repeated for each sex") byopts(title(My Overall Title)) subtitle("Extra info:", prefix)
    You can also add a subtitle within byopts().
    Last edited by Carole J. Wilson; 02 Apr 2016, 21:23. Reason: Added last line
    StataNow/MP 19.5 (64-bit x86-64)
    Win 11

    Comment


    • #3
      Originally posted by Carole J. Wilson View Post
      I find the byopts title a little counter intuitive in by graphs.
      Thanks for your comment Carole. I find it very counter intuitive too. I actually made two graphs and combined them. That gives me all I wanted. I was just wondering why something not working under 'marginsplot' that is legitimate with 'twoway' commands.
      By the way, just for learning purpose, how you would get rid off the shed that is automatically created with the 'by' option followed by 'marginsplot' ? I remember getting rid of the shed with the 'twoway' command, but can't find the file where it is now and not sure if that will work with 'marginsplot' when used with 'by' option. Any suggestion?

      Regards,
      Roman

      Comment


      • #4
        You'll notice that the "by" in marginsplot is not the same as the "by" in twoway. In marginsplot, the option by is an abbreviation for bydimension(dimlist,...) and takes the relevant arguments from the margins commands (not just any variable). In twoway, by(varlist,...) takes (any) variable list. So while the two were probably written to be similar, the differences are technically not inconsistencies in the "by" sub-options.

        I don't know what you mean by "shed"?
        StataNow/MP 19.5 (64-bit x86-64)
        Win 11

        Comment


        • #5
          Thanks again. I actually wanted to know, if you use "marginsplot, by(categories)" command, how would you get rid of the color that is automatically given for the two categories. 'graphregion' does not work within `by' option. See an example

          Click image for larger version

Name:	test.png
Views:	1
Size:	93.2 KB
ID:	1333861
          Roman

          Comment


          • #6
            My point is, there is no sub-option "by(categories)" in marginsplot. When you are specifying by(sex), you are saying bydimension(sex). Sex can't just be any variable, it has to be one of those in the margins command.


            The titles "Boys" and "Girls" are subtitles. To change the background color of a subtitle, you specify the textbox option -bcolor()- within the -subtitle()- option

            Code:
            marginsplot, by(Sex) ...subtitle(, bcolor(white) )
            *or, depending on your scheme
            marginsplot, by(Sex) ...subtitle(, bcolor(none) )


            StataNow/MP 19.5 (64-bit x86-64)
            Win 11

            Comment


            • #7
              Thanks Carole. 'bcol' I forgot. I used to use 'bgcol' which is an un-documented option but did not work in this case.
              Roman

              Comment

              Working...
              X