Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: estout and Nagelkerke R2


From   "Jann, Ben" <ben.jann@soz.gess.ethz.ch>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: estout and Nagelkerke R2
Date   Sat, 11 Sep 2004 17:16:39 +0200

Herve's code does not work because (a) the "nagelkerke.ado" does
not return anything and (b) the -calc()- suboption is misplaced. 

The following should do:

> 1st ado.file: "nagelkerke.ado"

program nagelkerke, rclass  // changed

local n=e(N)
local ml=e(ll)
local ml0=e(ll_0)
local k= e(df_m)
local r2_mcfadden = 1 - `ml'/`ml0'
local r2_cox = `r2_mcfadden' * (`n'-`k'-3) / (`n'-1)
local r2_nagelkerke = `r2_cox' / (1 - exp(2/`n'*`ml0'))

display `n'
display `ml'
display `ml0'
display `k'
display `r2_mcfadden'
display `r2_cox'
display `r2_nagelkerke'

return local r2_nagelkerke `r2_nagelkerke'  // added

end

> 2nd ado.file: _estout_stat_nagelkerke.ado

program _estout_stat_nagelkerke
quietly nagelkerke                  // changed 
c_local value "`r(r2_nagelkerke)'"  // changed
end

> In the master do file, I have the folowing syntax:

estout using logit_estout, replace ///
 cells(b(fmt(%9.3f)) t p) /// 
 stats(chi2 N r2_p, calc(nagelkerke) ///
   fmt(%9.3f %9.0f %9.3f %9.3f) ///
   labels("Chi square" "Number of observations" ///
      "Pseudo R-square" "Nagelkerke R-square")) ///
 label varlabels(_cons Constant)
 
ben

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index