Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Estout and number of observations


From   "raoul reulen" <r.c.reulen@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Estout and number of observations
Date   Mon, 26 Nov 2007 10:12:57 +0000

Brilliant! Thanks very much Ben.  I use the refcat option in estout,
but because the reference category does not appear in the regression
model it doesn't give me the number of observations for this category.
How can I get the number of observations for the reference category as
well? I have been trying to figure it out but couldn't do it. I would
be grateful for any suggestions.

On 21/11/2007, Ben Jann <ben.jann@gmail.com> wrote:
> This requires some programming. Here's an example;
>
> sysuse auto, clear
> xi: reg price weight i.rep
> capture matrix drop num
> foreach cat of varlist _Irep* {
>    count if `cat'==1 & e(sample)
>    matrix num = nullmat(num), r(N)
>    local collab "`collab'`cat' "
> }
> matrix colname num = `collab'
> estadd matrix num
> estout, cell("num b") style(smcl)
>
> which yields
>
> --------------------------------------
>                        .
>                      num            b
> --------------------------------------
> weight                        2.440292
> _Irep78_2               8     783.9009
> _Irep78_3              30     1379.115
> _Irep78_4              18     2068.267
> _Irep78_5              11     3245.272
> _cons                        -3000.405
> --------------------------------------
>
>
> ben
>
> On Nov 20, 2007 6:08 PM, Raoul Reulen <r.c.reulen@bham.ac.uk> wrote:
> > I am running a logistic regression model and save the estimates to estout. Now for a specific factor in the model I would also like to add the number of observations for each level of the factor.
> >
> >
> >
> > So for example;
> >
> >
> >
> > xi: logit dead i.diagnosis
> >
> > .estout . using "output/table2.xls",  cells("b(fmt(%9.1f)) ci(par( ( , ) ))") eform  replace
> >
> >
> >
> > Whereby::
> >
> > dead (yes=1, no=0)
> >
> > Diagnosis  (leukaemia=1, Hodgkins=2, retinoblastoma=3 etc)
> >
> >
> >
> > So this gives the estimates and confidence intervals for the factor diagnosis. How do I add the number of observations for each level of the factor diagnosis? So for example:
> >
> >
> >
> > Diagnosis          Number            estimate            95%CI
> >
> > Leukaemia        450                  3.0                   (2.0,5.0)
> >
> > Hodgkins          230                  4.9                   (3.0,8.4)
> >
> >
> >
> > How do I get a column with the number of observations such as in this example if possible?
> >
> >
> >
> > Thanks,
> >
> >
> >
> > Raoul
> >
> >
> > Raoul Reulen
> > Cancer Research UK Graduate Training Fellow
> >
> >
> > *
> > *   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/
> >
> *
> *   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/
>


-- 
-------------------------------------------------------
Raoul C. Reulen
Cancer Research UK Training Fellow
*
*   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