Announcement

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

  • What exactly does the "plus" option to regress do?

    The manual for -regress- says
    plus specifies that the output table be made extendable. This option is often used in programs and ado-files.
    What exactly does this option do? I can't see any difference between "regress price mpg" and "regress price mpg, plus".

    I looked in regress.ado, but as far as I can tell, it's only used in the syntax statement and then passed to a local macro. I thought it might be something involving custom tables, e.g. through the undocumented _tab class, but I couldn't find that reference anywhere either.


  • #2
    Wow! That is the most interesting question I've looked at recently. The answer is best shown by example. Below I run regress first without and then with the plus option. The difference lies in the character that I have highlighted in red in the last line of the output in each example. You will see that it is a character at the bottom of the vertical rule in the table, the rule separates the variable names from the results. Without the plus option, the character is a "-" as are all the other characters in the line, creating a solid line at the foot of the table. With the (now we realize suitably named) "plus option", it becomes a "+" so the vertical rule can be seamlessly extended to additional output that extends the basic table.

    I had to laugh when I finally saw it; hope others get a chuckle as well.

    Code:
    . sysuse auto
    (1978 Automobile Data)
    
    . regress mpg weight foreign
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(2, 71)        =     69.75
           Model |   1619.2877         2  809.643849   Prob > F        =    0.0000
        Residual |  824.171761        71   11.608053   R-squared       =    0.6627
    -------------+----------------------------------   Adj R-squared   =    0.6532
           Total |  2443.45946        73  33.4720474   Root MSE        =    3.4071
    
    ------------------------------------------------------------------------------
             mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          weight |  -.0065879   .0006371   -10.34   0.000    -.0078583   -.0053175
         foreign |  -1.650029   1.075994    -1.53   0.130      -3.7955    .4954422
           _cons |    41.6797   2.165547    19.25   0.000     37.36172    45.99768
    ------------------------------------------------------------------------------
    
    . regress mpg weight foreign, plus
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(2, 71)        =     69.75
           Model |   1619.2877         2  809.643849   Prob > F        =    0.0000
        Residual |  824.171761        71   11.608053   R-squared       =    0.6627
    -------------+----------------------------------   Adj R-squared   =    0.6532
           Total |  2443.45946        73  33.4720474   Root MSE        =    3.4071
    
    ------------------------------------------------------------------------------
             mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          weight |  -.0065879   .0006371   -10.34   0.000    -.0078583   -.0053175
         foreign |  -1.650029   1.075994    -1.53   0.130      -3.7955    .4954422
           _cons |    41.6797   2.165547    19.25   0.000     37.36172    45.99768
    -------------+----------------------------------------------------------------

    Comment


    • #3
      Good catch by William. Perhaps this is Stata's answer to Where's Waldo? Further, the plus option does NOT work if you use the svy: prefix. I suspect this is not because it makes the standard errors wrong, but because nobody wanted to bother getting it to work.

      As to why in the world you would want this option, the help for -ereturn display- says

      "plus changes the bottom separation line produced by ereturn display to have a + symbol at the position of the dividing line between variable names and results. This is useful if you plan on adding more output to the table."
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://academicweb.nd.edu/~rwilliam/

      Comment


      • #4
        Aha! I must admit to not having encountered the ereturn commands in my work to date. Thanks, Richard, I've learned something. A great question to included the Stata category of Trivial Pursuit Stats Nerd Edition, should that ever get written.

        Comment


        • #5
          Originally posted by William Lisowski View Post
          With the (now we realize suitably named) "plus option", it becomes a "+" so the vertical rule can be seamlessly extended to additional output that extends the basic table.
          Ah, thank you! I should have diff'ed the outputs instead of comparing them by sight alone. It's somewhat of a separate question, but can you give an example of how I would manually add output to a regression table? Code like this
          Code:
          sysuse auto, clear
          regress price mpg, plus
          
          // display SMCL here
          will always display the command following -regress- in between the regression table and the later output, so the table isn't continued seamlessly.



          Comment


          • #6
            Probably the easiest way is to embed the commands within a simple Stata program. There are other alternatives involving the quietly and noisily commands, but a program is the most elegant, and most appropriate, approach approach.
            Code:
            capture program drop demo
            program demo
            regress price mpg, plus
            foreach threat in fee fi fo fum {
                display %12s "`threat'" _column(14) "{c |} oooh!"
                }
            end
            
            sysuse auto, clear
            demo
            exit
            produces
            Code:
            . demo
            
                  Source |       SS           df       MS      Number of obs   =        74
            -------------+----------------------------------   F(1, 72)        =     20.26
                   Model |   139449474         1   139449474   Prob > F        =    0.0000
                Residual |   495615923        72  6883554.48   R-squared       =    0.2196
            -------------+----------------------------------   Adj R-squared   =    0.2087
                   Total |   635065396        73  8699525.97   Root MSE        =    2623.7
            
            ------------------------------------------------------------------------------
                   price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                     mpg |  -238.8943   53.07669    -4.50   0.000    -344.7008   -133.0879
                   _cons |   11253.06   1170.813     9.61   0.000     8919.088    13587.03
            -------------+----------------------------------------------------------------
                     fee | oooh!
                      fi | oooh!
                      fo | oooh!
                     fum | oooh!
            Note the use of the SMCL "{c |} character for the vertical line; this sample output looks much better viewed within Stata's Results window, where the SMCL has full effect.

            Chapter 18 of the Stata User's Guide has much more detail on writing programs.

            Added in edit: An alternative is to create a do-file, then execute it using the run command rather than the do command. With run the commands in the file are not echoed, as the are with do. But if you're in the habit of running commands from the do-file editor window, you'll (a) want to be sure the run icon is on the toolbar next to the do icon and (b) remember to run rather than do, as necessary. You can guess that this is not the approach I take.
            Last edited by William Lisowski; 18 Jul 2016, 07:59.

            Comment

            Working...
            X