--- [email protected] wrote:
> In this respect, I just would like to know how one can obtain a
> scalar of fit indices from a logistic regression model.
>
> For instance,
>
> . logistic status factor1 factor2 [freq=count]
> . estat ic,
>
> ---------------------------------------------------------------------
> Model | Obs ll(null) ll(model) df AIC BIC
> -------------+-------------------------------------------------------
> . | 249 -165.5368 -159.3161 2 322.6321
> 329.667
> ---------------------------------------------------------------------
>
> How could one get that AIC value of 322.6321 into a scalar?
The fit statistics are stored in the matrix r(S). You can turn that
into a matrix called s, and than use -el- to extract the scalar you
want. See example below. Using -tempname- here is a safety feature (as
you are often programming) which makes sure you are not changing any
other matrices or scalars that are already in memory and happen to have
the same name. Also if you have a variable name starting with aic than
that will take precedence when you type -di aic-. Something that can
lead to very confusing results. With tempname you are always sure that
`aic' will refer to the scalar `aic' and not to some variable whose
name starts with the same characters.
*----------- begin example -----------
sysuse auto, clear
logit foreign mpg
estat ic
tempname s aic
matrix `s' = r(S)
scalar `aic' = el(`s',1,5)
di `aic'
*----------- end example --------------
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
___________________________________________________________
Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html
*
* 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/