Announcement

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

  • Adding fixed effects in esttab using estadd

    Hi all,

    I've run a few regressions and am trying to add rows indicating the presence of fixed effects, control variables etc to the output table. Following some of the earlier posts on this topic, I used the following code:
    Code:
    eststo clear
    
    eststo: areg y x  c1 c2 ib(first).round,a(id)
    estadd local household "Yes"
    estadd local control "Yes"
    
    eststo: areg z x c1 c2  ib(first).round,a(id)
    estadd local household "Yes"
    estadd local control "Yes"
    
    esttab est1 est2 using "filepath\1_xyz.tex", s(N household control , label("N" "Household FE" "Control variables"))se ar2 starlevels(* 0.10 ** 0.05 *** 0.01)                            ///
            title(Regression 1)
    esttab is from SSC

    However, I'm getting the error:
    Code:
    file \1_xyz.tex could not be opened
    But i have earlier used
    Code:
    esttab est1 est2 using "filepath\1_xyz.tex", se ar2 starlevels(* 0.10 ** 0.05 *** 0.01)
    without estadd, or s(), and it has worked fine.

    Would appreciate if someone tells me what I'm doing wrong here and how to go about this problem.

    Thanks

  • #2
    I cannot reproduce your problem. Either the file is already open or there is a problem with your file path. I would just use -using xyz.tex- to save it in your current directory and -replace- to overwrite any existing content. The following works for me:

    Code:
    sysuse auto, clear
    regress mpg weight disp
    estadd local household "Yes"
    estadd local control "Yes"
    esttab using myfile.tex, s(N household control) replace
    Res.:

    Code:
    . regress mpg weight disp
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(2, 71)        =     66.79
           Model |  1595.40969         2  797.704846   Prob > F        =    0.0000
        Residual |  848.049768        71  11.9443629   R-squared       =    0.6529
    -------------+----------------------------------   Adj R-squared   =    0.6432
           Total |  2443.45946        73  33.4720474   Root MSE        =    3.4561
    
    ------------------------------------------------------------------------------
             mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          weight |  -.0065671   .0011662    -5.63   0.000    -.0088925   -.0042417
    displacement |   .0052808   .0098696     0.54   0.594    -.0143986    .0249602
           _cons |   40.08452    2.02011    19.84   0.000     36.05654    44.11251
    ------------------------------------------------------------------------------
    
    . 
    . estadd local household "Yes"
    
    added macro:
              e(household) : "Yes"
    
    . 
    . estadd local control "Yes"
    
    added macro:
                e(control) : "Yes"
    
    . esttab using myfile.tex, s(N household control) replace
    (note: file myfile.tex not found)
    (output written to myfile.tex)

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      I cannot reproduce your problem. Either the file is already open or there is a problem with your file path. I would just use -using xyz.tex- to save it in your current directory and -replace- to overwrite any existing content. The following works for me:

      Code:
      sysuse auto, clear
      regress mpg weight disp
      estadd local household "Yes"
      estadd local control "Yes"
      esttab using myfile.tex, s(N household control) replace
      Res.:

      Code:
      . regress mpg weight disp
      
      Source | SS df MS Number of obs = 74
      -------------+---------------------------------- F(2, 71) = 66.79
      Model | 1595.40969 2 797.704846 Prob > F = 0.0000
      Residual | 848.049768 71 11.9443629 R-squared = 0.6529
      -------------+---------------------------------- Adj R-squared = 0.6432
      Total | 2443.45946 73 33.4720474 Root MSE = 3.4561
      
      ------------------------------------------------------------------------------
      mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
      -------------+----------------------------------------------------------------
      weight | -.0065671 .0011662 -5.63 0.000 -.0088925 -.0042417
      displacement | .0052808 .0098696 0.54 0.594 -.0143986 .0249602
      _cons | 40.08452 2.02011 19.84 0.000 36.05654 44.11251
      ------------------------------------------------------------------------------
      
      .
      . estadd local household "Yes"
      
      added macro:
      e(household) : "Yes"
      
      .
      . estadd local control "Yes"
      
      added macro:
      e(control) : "Yes"
      
      . esttab using myfile.tex, s(N household control) replace
      (note: file myfile.tex not found)
      (output written to myfile.tex)
      Thanks a lot Andrew! Also, you were right: there was a problem in the file path.

      Comment

      Working...
      X