Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Re: RE: RE: R2 stats using statsby or parmby???


From   "Joao Ricardo F. Lima" <jricardofl@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Re: RE: RE: R2 stats using statsby or parmby???
Date   Sat, 27 Jun 2009 23:50:32 -0300

Hugh,

I don't understand why you can't use -fitstat- with spost9_ado.

----------------------------------------------------------------------------------------------------------------------------------------------------------
package spost9_ado from http://www.indiana.edu/~jslsoc/stata
----------------------------------------------------------------------------------------------------------------------------------------------------------

TITLE
      Distribution-date: 26May2009

DESCRIPTION/AUTHOR(S)
      spost9_ado Stata 9 & 10 commands for the post-estimation interpretation
      of regression models. Use package spostado.pkg for Stata 8.
      Based on Long & Freese - Regression Models for Categorical Dependent
      Variables Using Stata. Second Edition.
      Support www.indiana.edu/~jslsoc/spost.htm
      Scott Long & Jeremy Freese (spostsup@indiana.edu)


****begin example****
use http://www.ats.ucla.edu/stat/stata/dae/logit.dta, clear
logit admit gre topnotch gpa
fitstat
ret li
********

. logit admit gre topnotch gpa

Iteration 0:   log likelihood = -249.98826
Iteration 1:   log likelihood = -239.17277
Iteration 2:   log likelihood = -239.06484
Iteration 3:   log likelihood = -239.06481

Logistic regression                               Number of obs   =        400
                                                  LR chi2(3)      =      21.85
                                                  Prob > chi2     =     0.0001
Log likelihood = -239.06481                       Pseudo R2       =     0.0437

------------------------------------------------------------------------------
       admit |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         gre |   .0024768   .0010702     2.31   0.021     .0003792    .0045744
    topnotch |   .4372236   .2918532     1.50   0.134    -.1347983    1.009245
         gpa |   .6675556   .3252593     2.05   0.040     .0300592    1.305052
       _cons |  -4.600814   1.096379    -4.20   0.000    -6.749678   -2.451949
------------------------------------------------------------------------------

. fitstat

Measures of Fit for logit of admit

Log-Lik Intercept Only:       -249.988   Log-Lik Full Model:           -239.065
D(396):                        478.130   LR(3):                          21.847
                                         Prob > LR:                       0.000
McFadden's R2:                   0.044   McFadden's Adj R2:               0.028
ML (Cox-Snell) R2:               0.053   Cragg-Uhler(Nagelkerke) R2:      0.074
McKelvey & Zavoina's R2:         0.075   Efron's R2:                      0.052
Variance of y*:                  3.558   Variance of error:               3.290
Count R2:                        0.683   Adj Count R2:                    0.000
AIC:                             1.215   AIC*n:                         486.130
BIC:                         -1894.490   BIC':                           -3.873
BIC used by Stata:             502.095   AIC used by Stata:             486.130

. ret li

scalars:
           r(stataaic) =  486.1296167502151
           r(statabic) =  502.095474938647
              r(bic_p) =  -3.872507163376337
                r(bic) =  -1894.490343904546
              r(aic_n) =  486.1296167502151
                r(aic) =  1.215324041875538
           r(r2_ctadj) =  0
              r(r2_ct) =  .6825
            r(v_error) =  3.289868133696453
            r(v_ystar) =  3.558261449065467
              r(r2_ef) =  .0516798400622276
              r(r2_mz) =  .0754282166195246
              r(r2_cu) =  .0744977264693392
              r(r2_ml) =  .0531525174232285
           r(r2_mfadj) =  .0276951023068386
              r(r2_mf) =  .0436958537803742
             r(lrx2_p) =  .0000701949508804
               r(lrx2) =  21.84690080470028
                r(dev) =  478.1296167502151
                 r(ll) =  -239.0648083751076
               r(ll_0) =  -249.9882587774577
                  r(N) =  400
              r(n_rhs) =  3
             r(n_parm) =  4
            r(lrx2_df) =  3
             r(dev_df) =  396


HTH,

Joao Lima

2009/6/27 Hugh Robinson <hugh.robinson@umontana.edu>:
> Thanks Martin - you've got me moving forward again.
>
> You wouldn't happen to know how to get the model pseudo r-square
> displayed would you?  In Roger's post below he suggests that parmby
> calculates and stores it as r2_p, but I don't see it.
>
>
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
> Sent: Saturday, June 27, 2009 3:44 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Re: RE: RE: R2 stats using statsby or parmby???
>
> <>
>
> Not sure whether that blank after -flist-- hurt you, but you should use
> line
> continuation  "///". Also note that -by- likes to be passed a dataset
> sorted
> by its -varlist-, so append an "s" to make it "bysort"...
>
> ***
> use http://www.ats.ucla.edu/stat/stata/dae/logit.dta, clear
> global tflist ""
> global modseq=0
> foreach X in gre topnotch gpa {
> global modseq=$modseq+1
> tempfile tf$modseq
> parmby "logit admit `X'", label  ///
> command format(estimate min95 max95 ///
> %8.2f p %8.1e) idn($modseq)  ///
> saving(`tf$modseq',replace) ///
> flist(tflist)
> }
> dsconcat $tflist
> sort idnum parmseq
> describe
> bys idnum command:list parm ///
>  label estimate min95 max95 p,noobs
> ***
>
>
> HTH
> Martin
> _______________________
> ----- Original Message -----
> From: "Hugh Robinson" <hugh.robinson@umontana.edu>
> To: <statalist@hsphsun2.harvard.edu>
> Sent: Saturday, June 27, 2009 11:10 PM
> Subject: st: RE: RE: R2 stats using statsby or parmby???
>
>
>> Roger,
>>
>> I was intrigued by reading your response to this posting, I think the
>> foreach and parmby commands could be very helpful for me in running a
>> number of univariat logits and producing a single table containing
> each
>> variable name, its coefficient, p-value, and r-square value.
>>
>> Towards that goal I thought I would start with the UCLA sample logit
>> data and try to modify the command list from the parmby help file to
>> create something looks like what I'm after.
>>
>> When I run the following code the foreach loop only gets as far the
>> first covariate "gre" then produces an error that reads "variable
> tflist
>> not found".
>>
>> Can you see what's wrong?
>>
>>
>> Thanks
>> HR
>>
>>
>> use http://www.ats.ucla.edu/stat/stata/dae/logit.dta, clear
>> global tflist ""
>> global modseq=0
>> foreach X in gre topnotch gpa {
>> global modseq=$modseq+1
>> tempfile tf$modseq
>> parmby "logit admit `X'", label command format(estimate min95 max95
>> %8.2f p %8.1e) idn($modseq) saving(`tf$modseq',replace)
>> flist (tflist)
>> }
>> dsconcat $tflist
>> sort idnum parmseq
>> describe
>> by idnum command:list parm label estimate min95 max95 p,noobs
>>
>>
>>
>>
>> -----Original Message-----
>> From: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Newson,
> Roger
>> B
>> Sent: Friday, June 26, 2009 1:07 PM
>> To: 'statalist@hsphsun2.harvard.edu'
>> Subject: st: RE: R2 stats using statsby or parmby???
>>
>> You do not specify what goodness-of-fit statistic you want, or which
>> program you are using to do your logistic regression (O prefer -glm-,
>> but many other people prefer -logit- or -logistic-). However, if the
>> goodness-of-fit statistic is saved in e(), then either -statsby- or
>> -parmby- can save it. In the case of -parmby-, you use the -escal()-
>> option to save extra scalar results. As in
>>
>> parmby "glm y x, link(logit) family(bin) eform robust", eform
> norestore
>> by(group) escal(aic bic chi2 dispers_p)
>>
>> which should save -e(aic)-, -e(bic)-, -e(chi2)- and -e(dispers_p)- in
>> scalar variables named -es_1-, -es_2-, -es_3-, and -es_4-,
> respectively.
>> You can give them more informative names using the -rename()- option.
>> Similarly, the -logit- and -logistic- commands save the
> pseudo-R-squared
>> in -e(r2_p)-.
>>
>> I hope this helps.
>>
>> Best wishes
>>
>> Roger
>>
>>
>> Roger B Newson BSc MSc DPhil
>> Lecturer in Medical Statistics
>> Respiratory Epidemiology and Public Health Group
>> National Heart and Lung Institute
>> Imperial College London
>> Royal Brompton Campus
>> Room 33, Emmanuel Kaye Building
>> 1B Manresa Road
>> London SW3 6LR
>> UNITED KINGDOM
>> Tel: +44 (0)20 7352 8121 ext 3381
>> Fax: +44 (0)20 7351 8322
>> Email: r.newson@imperial.ac.uk
>> Web page: http://www.imperial.ac.uk/nhli/r.newson/
>> Departmental Web page:
>>
> http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/pop
>> genetics/reph/
>>
>> Opinions expressed are those of the author, not of the institution.
>>
>> -----Original Message-----
>> From: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Thomas M
>> Holbrook
>> Sent: 26 June 2009 18:09
>> To: statalist@hsphsun2.harvard.edu
>> Subject: st: R2 stats using statsby or parmby???
>>
>> I'm trying to find a way the generate goodness-of-fit stats for logit
>> models run separately over subgroups of my my data (I'm running a vote
>> model using individual-level data and I want to generate fit stats by
>> day of the campaign).  I can get the slopes and standard errors using
>> "statsby" or "parmby" but I don't set a way of generating the fit
> stats.
>> Any ideas???
>>
>> -Tom
>>
>> Thomas M. Holbrook
>>
>> Wilder Crane Professor of Government
>> Department of Political Science
>> University of Wisconsin-Milwaukee
>> 3210 North Maryland Avenue
>> Milwaukee, WI  53211
>>
>> www.uwm.edu/~holbroot
>> www.election08data.blogspot.com
>>
>> 414-229-6468
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>



-- 
----------------------------------------
Joao Ricardo Lima, D.Sc.
Professor
UFPB-CCA-DCFS
Fone: +5538387264913
Skype: joao_ricardo_lima
----------------------------------------

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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