Announcement

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

  • Stars of significance with File Write

    Hi,

    I'm trying to export regression results using "file write" but can't seem to figure out how to add the stars of significance. Does anyone know the syntax for it?

    I use "file write _tab (_b[var1]) " to get the coefficient. But (star[var1]) does not work.

    Thanks!

  • #2
    Welcome to Statalist!

    Unfortunately, while Stata provides built-in system variables like _b[var1] and _se[var1] for each independent variable in a regression (see the output of help _variables for details) there is no equivalent for other results, like significance stars.

    There are several user-written programs that assist in producing files containing regression results. The program estout and its associated programs are often mentioned on Statalist, although I have not used them. If you type net sj 14-2 st0085_2 you will see links to install the programs, or to review the help files online before installation.


    Comment


    • #3
      There are several i.e. outreg, outreg2, estout, putexcel etc., below is an example with 'estout'

      Code:
      ssc install estout //install this
      
      Example:
      
      sysuse auto,clear
      
      
      reg price mpg
      
      est sto m1
      
      reg price mpg foreign
      
      est sto m2
      
      reg price mpg foreign weight
      
      est sto m3
      
      estout m1 m2 m3 , modelwidth(20) cells(b(fmt(2)) ci(par(`"("' `"-"' `")"') fmt(2)star))
      
      Output:
      
      
       ------------------------------------------------------------------------------------
                                     m1                      m2                      m3  
                                 b/ci95                  b/ci95                  b/ci95  
      ------------------------------------------------------------------------------------
      mpg                       -238.89                 -294.20                   21.85  
                      (-344.70--133.09)***    (-405.24--183.15)***     (-126.18-169.88)  
      foreign                                           1767.29                 3673.06  
                                               (371.22-3163.37)*      (2308.91-5037.21)***
      weight                                                                       3.46  
                                                                            (2.21-4.72)***
      _cons                    11253.06                11905.42                -5853.70  
                     (8919.09-13587.03)***   (9595.16-14215.67)***   (-12588.88-881.49)  
      ------------------------------------------------------------------------------------
      
      
      help estout
      Last edited by Roman Mostazir; 27 Jan 2016, 12:37.
      Roman

      Comment


      • #4
        Thank you for your help! I calculated the p-values and got the stars to display.

        Comment


        • #5
          I also was able to get the stars to display by hand-coding the p-values. Here is some example code to do this:

          Code:
          sysuse auto, clear
          
          qui reg price mpg headroom i.foreign 
          local b1A = _b[mpg]
          local se1A = _se[mpg]
               if inrange(2 * ttail(e(df_r), abs(_b[mpg]/_se[mpg])),0.000000000,0.01) local star1A = "***"
          else if inrange(2 * ttail(e(df_r), abs(_b[mpg]/_se[mpg])),0.010000001,0.05) local star1A = "**"
          else if inrange(2 * ttail(e(df_r), abs(_b[mpg]/_se[mpg])),0.050000001,0.10) local star1A = "*"
          else local star1A = " "
          local N1A = `e(N)'
          est sto regA
          
          di `b1A'
          di `se1A'
          di "`star1A'"
          
          capture file close T2
          file open T2 using "${table_path}T2.tex", write append
          file write T2 "MPG & " %7.3f (`b1A') "`star1A'"  " \\ "  _n 
          file close T2

          Comment

          Working...
          X