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

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

From   "Hugh Robinson" <>
To   <>
Subject   st: RE: RE: R2 stats using statsby or parmby???
Date   Sat, 27 Jun 2009 15:10:22 -0600


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?


use, 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
by idnum command:list parm label estimate min95 max95 p,noobs

-----Original Message-----
[] On Behalf Of Newson, Roger
Sent: Friday, June 26, 2009 1:07 PM
To: ''
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 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
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Web page:
Departmental Web page:

Opinions expressed are those of the author, not of the institution.

-----Original Message-----
[] On Behalf Of Thomas M
Sent: 26 June 2009 18:09
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???


Thomas M. Holbrook

Wilder Crane Professor of Government
Department of Political Science
University of Wisconsin-Milwaukee
3210 North Maryland Avenue
Milwaukee, WI  53211

*   For searches and help try:

*   For searches and help try:

*   For searches and help try:

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