Announcement

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

  • Pulling the log likelihood into outreg2

    Hello,

    I'd like to add the log likelihood ratio to outreg2 output. Two problems that I'm having (1) Outreg2 is not able to open documents that I run, (2) I am unsure how to add the log likelihood.

    In time, I think I will be able to figure out the mapping issue with outreg2 and am most keen on advice from the community about how to specify the log likelihood in the outreg2 command.

    Thanks so much!
    Preeti

    Below is a code example using auto.dta from Stata:

    Code:
    . logit foreign rep78
    
    Iteration 0:   log likelihood = -42.400729  
    Iteration 1:   log likelihood = -28.730111  
    Iteration 2:   log likelihood = -27.728894  
    Iteration 3:   log likelihood = -27.716046  
    Iteration 4:   log likelihood = -27.716037  
    Iteration 5:   log likelihood = -27.716037  
    
    Logistic regression                             Number of obs     =         69
                                                    LR chi2(1)        =      29.37
                                                    Prob > chi2       =     0.0000
    Log likelihood = -27.716037                     Pseudo R2         =     0.3463
    
    ------------------------------------------------------------------------------
         foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           rep78 |   1.969267   .4785224     4.12   0.000      1.03138    2.907154
           _cons |  -8.043597   1.848757    -4.35   0.000    -11.66709     -4.4201
    ------------------------------------------------------------------------------
    
    . outreg2 using test.doc, replace ctitle(logit coeff)
    file test.txt could not be opened
    r(603);



  • #2
    If you read the documentation, it has a subsection on adding r() and e() statistics to the output. If you type ereturn list after running logit, you'll see that it saves the log likelihood in e(ll).

    As for not writing, check first that you don't have the test.txt file open in another program. If not that, then you're probably using a default directory to which you cannot write. Either use cd to change the directory before outreg2 (cd "C:\MyProject") or use a full directory in specifying your output file - like " using "C:\MyProject\test.txt".

    Comment

    Working...
    X