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

Re: st: RE: estout and Nagelkerke R2

From   "Herve STOLOWY" <>
To   <>
Subject   Re: st: RE: estout and Nagelkerke R2
Date   Sat, 11 Sep 2004 11:50:48 +0200

Dear Ben:

I used the new version of estout but still face some difficulty. I am obliged to provide some elements of programming.

Following your suggestions, I created several ado.files:

1st ado.file: "nagelkerke.ado"

program nagelkerke

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'


2nd ado.file: _estout_stat_nagelkerke.ado

program _estout_stat_nagelkerke
c_local value "`r2_nagelkerke'"

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

estout using logit_estout, replace  cells (b(fmt(%9.3f)) t(fmt(%9.3f)) p(fmt(%9.3f))) 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)

Everything works, except that I do not get any figure on the "Nagelkerke r-square" line. I have no error message.

I made several checks:

- I am sure of the computation of the Nagelkerke r-square because the ado.file works separately.
- The two ado.files are located in the right directory.

Could you help me to find what's going wrong?

Best regards

Herve Stolowy
HEC Paris
Département Comptabilité-Contrôle de gestion / Dept of Accounting and Management Control
1, rue de la Liberation
78351 - Jouy-en-Josas
Tel: +33 1 39 67 94 42
Fax: +33 1 39 67 70 86
>>> 09/10/04 10:47 PM >>>
Herve wrote:
> After a logit, I created a do-file which computes the Nagelkerke R2.
> I would like to add this figure to the table of results with 
> estout. Is it possible? 

It is possible, needs some minimal programming, though (see the 
"Programming subroutines" section in the helpfile; further 
explanations are given in the file "_estout_stat_p.ado", 
which is part of the -estout- package). 

(Please make sure that you are running the latest version 
of -estout-!)

Suppose your program is called -Nagelkerke- and returns 
Nagelkerke R2 in -r(nagelkerke)-. Then save the program

    program _estout_stat_nagelkerke
        c_local value "`r(nagelkerke)'"

as "_estout_stat_nagelkerke.ado" in the current directory 
or somewhere else in the ado-path (or just include the 
program in your do-file). Then type

 . estout ..., stats(chi2 N r2_p, calc(nagelkerke))

To change the order of the statistics, type, e.g.

 . estout ..., stats(chi2 N nagelkerke r2_p, calc(nagelkerke))

Another possibility is, of course, to write a program which 
adds e(nagelkerke) to the e-returns of the estimates.


*   For searches and help try:

*   For searches and help try:

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