Announcement

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

  • how to change the order of variables in interaction for esttab

    Code:
    sysuse auto,clear
    reg price c.mpg##i.foreign
    esttab
    I want to change "foreign#c.mpg" to "c.mpg#foreign" for the rtf file, how to set this?
    Thanks so much!

  • #2
    Please do not disregard FAQ Advice #12 that asks you to state the provenance of community-contributed commands if you reference them. estout is from the Stata Journal/ SSC. See the option -coeflab-

    Code:
    sysuse auto,clear
    reg price c.mpg##i.foreign
    esttab, coeflab(1.foreign#c.mpg  "c.mpg#foreign") nobaselevels
    Res.:

    Code:
    . esttab, coeflab(1.foreign#c.mpg  "c.mpg#foreign") nobaselevels
    
    ----------------------------
                          (1)   
                        price   
    ----------------------------
    mpg                -329.3***
                      (-4.39)   
    
    1.foreign          -13.59   
                      (-0.01)   
    
    c.mpg#fore~n        78.89   
                       (0.70)   
    
    _cons             12600.5***
                       (8.25)   
    ----------------------------
    N                      74   
    ----------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001

    Comment


    • #3
      I see. Thanks so much!

      Comment


      • #4
        Originally posted by Andrew Musau View Post
        Please do not disregard FAQ Advice #12 that asks you to state the provenance of community-contributed commands if you reference them. estout is from the Stata Journal/ SSC. See the option -coeflab-

        Code:
        sysuse auto,clear
        reg price c.mpg##i.foreign
        esttab, coeflab(1.foreign#c.mpg "c.mpg#foreign") nobaselevels
        Res.:

        Code:
        . esttab, coeflab(1.foreign#c.mpg "c.mpg#foreign") nobaselevels
        
        ----------------------------
        (1)
        price
        ----------------------------
        mpg -329.3***
        (-4.39)
        
        1.foreign -13.59
        (-0.01)
        
        c.mpg#fore~n 78.89
        (0.70)
        
        _cons 12600.5***
        (8.25)
        ----------------------------
        N 74
        ----------------------------
        t statistics in parentheses
        * p<0.05, ** p<0.01, *** p<0.001
        I was wondering why Stata changed the order I input, no matter I input
        Code:
         
         c.mpg##i.foreign or   
         i.foreign##c.mpg
        Is that possible to change the results displayed in Stata?

        Comment


        • #5
          You cannot change it, that is the convention adopted by Stata when using factor variables. I also do not see what you want to achieve by doing so.

          Comment


          • #6
            Originally posted by Andrew Musau View Post
            You cannot change it, that is the convention adopted by Stata when using factor variables. I also do not see what you want to achieve by doing so.
            If I change this, esttab will automatically use the order I set, I don't need to set the coeflabels anymore. I have three-way interaction, I need to set the labels of every interactoin term, it is a little redundant.

            Comment


            • #7
              You can order coefficients using the -order()- option as well.

              Comment


              • #8
                Originally posted by Andrew Musau View Post
                You can order coefficients using the -order()- option as well.
                Thanks Andrew! However, I want to only exchange the order of foreign and mpg in the example. If I set order (mpg foreign), the two variables will come to first two rows which is not I expected. If list a customized order of all variables, it is also quite redundant. Can we have elegant ways to solve this?

                Comment


                • #9
                  For exchange, I mean the order is :
                  mpg
                  foreign
                  mpg * foreign

                  Comment


                  • #10
                    You cannot do this apart from relabeling the coefficients one at a time using -coeflabel-.

                    Comment


                    • #11
                      Originally posted by Andrew Musau View Post
                      You cannot do this apart from relabeling the coefficients one at a time using -coeflabel-.
                      I see, thank you!

                      Comment

                      Working...
                      X