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

st: RE: -by- with -binreg-


From   "Nick Winter" <nwinter@policystudies.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: -by- with -binreg-
Date   Wed, 4 Dec 2002 15:44:09 -0500

Looking at the ado code for -binreg-, it seems that -binreg- is a
wrapper for -glm-, and that the call to -glm- does not preserve the "by
varlist:" that you specify.

This should be a quick thing for SstataCorp to fix.  In the mean time,
you can just call -glm- directly, which does properly support "by
varlist:".  The (undocumented?) "cmd" option of -binreg- seems to tell
you the necessary -glm- syntax.

Nick Winter

> -----Original Message-----
> From: Lee Sieswerda [mailto:Lee.Sieswerda@tbdhu.com] 
> Sent: Wednesday, December 04, 2002 3:31 PM
> To: Statalist (E-mail)
> Subject: st: -by- with -binreg-
> 
> 
> Dear Statalisters:
> For some reason I cannot get -by- to work with -binreg-. I 
> can get around
> the problem using -if-, but according to the manual I should 
> be able to use
> -by-. Here is my log:
> 
> . table pre_post sex, c(mean q7cat)
> 
> ------------------------------
>           |        sex        
>  pre_post |        F         M
> ----------+-------------------
>       pre | .3238095  .4953271
>      post |       .6  .6296296
> ------------------------------
> 
> * Both sexes together
> . binreg q7cat pre_post, rd cluster(id)
> 
> Iteration 1 : deviance =  570.9529
> Iteration 2 : deviance =  570.9529
> 
> Residual df  =       423                                No. of obs =
> 425
> Pearson X2   =       425                                Deviance   =
> 570.9529
> Dispersion   =  1.004728                                Dispersion =
> 1.349771
> 
> Bernoulli distribution, identity link
> Risk difference coefficients
>                                (standard errors adjusted for 
> clustering on
> id)
> --------------------------------------------------------------
> --------------
> --
>              |             Semi-Robust
>        q7cat |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
> Interval]
> -------------+------------------------------------------------
> --------------
> --
>     pre_post |   .2046461   .0391639     5.23   0.000     .1278862
> .281406
>        _cons |   .2057312   .0651479     3.16   0.002     .0780438
> .3334187
> --------------------------------------------------------------
> --------------
> --
> 
> * Try to get separate estimates by sex
> 
> . bysort sex: binreg q7cat pre_post, rd cluster(id)
> 
> ______________________________________________________________
> ______________
> ___
> -> sex = F
> 
> Iteration 1 : deviance =  570.9529
> Iteration 2 : deviance =  570.9529
> 
> Residual df  =       423                                No. of obs =
> 425
> Pearson X2   =       425                                Deviance   =
> 570.9529
> Dispersion   =  1.004728                                Dispersion =
> 1.349771
> 
> Bernoulli distribution, identity link
> Risk difference coefficients
>                                (standard errors adjusted for 
> clustering on
> id)
> --------------------------------------------------------------
> --------------
> --
>              |             Semi-Robust
>        q7cat |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
> Interval]
> -------------+------------------------------------------------
> --------------
> --
>     pre_post |   .2046461   .0391639     5.23   0.000     .1278862
> .281406
>        _cons |   .2057312   .0651479     3.16   0.002     .0780438
> .3334187
> --------------------------------------------------------------
> --------------
> --
> 
> ______________________________________________________________
> ______________
> ___
> -> sex = M
> 
> Iteration 1 : deviance =  570.9529
> Iteration 2 : deviance =  570.9529
> 
> Residual df  =       423                                No. of obs =
> 425
> Pearson X2   =       425                                Deviance   =
> 570.9529
> Dispersion   =  1.004728                                Dispersion =
> 1.349771
> 
> Bernoulli distribution, identity link
> Risk difference coefficients
>                                (standard errors adjusted for 
> clustering on
> id)
> --------------------------------------------------------------
> --------------
> --
>              |             Semi-Robust
>        q7cat |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
> Interval]
> -------------+------------------------------------------------
> --------------
> --
>     pre_post |   .2046461   .0391639     5.23   0.000     .1278862
> .281406
>        _cons |   .2057312   .0651479     3.16   0.002     .0780438
> .3334187
> --------------------------------------------------------------
> --------------
> --
> 
> * Since that gave the same results as if I hadn't used
> * -by- at all, try -if- instead
> 
> . binreg q7cat pre_post if sex=="M", rd cluster(id)
> 
> Iteration 1 : deviance =  290.7011
> Iteration 2 : deviance =  290.7011
> 
> Residual df  =       213                                No. of obs =
> 215
> Pearson X2   =       215                                Deviance   =
> 290.7011
> Dispersion   =   1.00939                                Dispersion =
> 1.364794
> 
> Bernoulli distribution, identity link
> Risk difference coefficients
>                                (standard errors adjusted for 
> clustering on
> id)
> --------------------------------------------------------------
> --------------
> --
>              |             Semi-Robust
>        q7cat |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
> Interval]
> -------------+------------------------------------------------
> --------------
> --
>     pre_post |   .1343025   .0536422     2.50   0.012     .0291657
> .2394394
>        _cons |   .3610246   .0910578     3.96   0.000     .1825546
> .5394945
> --------------------------------------------------------------
> --------------
> --
> 
> . binreg q7cat pre_post if sex=="F", rd cluster(id)
> 
> Iteration 1 : deviance =  273.5711
> Iteration 2 : deviance =  273.5711
> 
> Residual df  =       208                                No. of obs =
> 210
> Pearson X2   =       210                                Deviance   =
> 273.5711
> Dispersion   =  1.009615                                Dispersion =
> 1.315246
> 
> Bernoulli distribution, identity link
> Risk difference coefficients
>                                (standard errors adjusted for 
> clustering on
> id)
> --------------------------------------------------------------
> --------------
> --
>              |             Semi-Robust
>        q7cat |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
> Interval]
> -------------+------------------------------------------------
> --------------
> --
>     pre_post |   .2761905   .0566061     4.88   0.000     .1652445
> .3871365
>        _cons |    .047619   .0911676     0.52   0.601    -.1310661
> .2263042
> --------------------------------------------------------------
> --------------
> --
> 
> * Suppose I use -regress- instead of -binreg-. Then can I use -by-?
> . by sex: regress q7cat pre_post, cluster(id)
> 
> ______________________________________________________________
> ______________
> ___
> -> sex = F
> 
> Regression with robust standard errors                 Number of obs =
> 210
>                                                        F(  1,   104) =
> 23.69
>                                                        Prob > F      =
> 0.0000
>                                                        R-squared     =
> 0.0767
> Number of clusters (id) = 105                          Root MSE      =
> .48134
> 
> --------------------------------------------------------------
> --------------
> --
>              |               Robust
>        q7cat |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
> Interval]
> -------------+------------------------------------------------
> --------------
> --
>     pre_post |   .2761905   .0567421     4.87   0.000     .1636688
> .3887121
>        _cons |    .047619   .0913865     0.52   0.603    -.1336038
> .2288419
> --------------------------------------------------------------
> --------------
> --
> 
> ______________________________________________________________
> ______________
> ___
> -> sex = M
> 
> Regression with robust standard errors                 Number of obs =
> 215
>                                                        F(  1,   108) =
> 6.24
>                                                        Prob > F      =
> 0.0140
>                                                        R-squared     =
> 0.0183
> Number of clusters (id) = 109                          Root MSE      =
> .49378
> 
> --------------------------------------------------------------
> --------------
> --
>              |               Robust
>        q7cat |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
> Interval]
> -------------+------------------------------------------------
> --------------
> --
>     pre_post |   .1343025    .053768     2.50   0.014      .027725
> .2408801
>        _cons |   .3610246   .0912713     3.96   0.000     .1801091
> .5419401
> --------------------------------------------------------------
> --------------
> --
> 
> So in this case -regress- works with -by-, but -binreg- does 
> not. I also
> have sex as a numeric variable, but that doesn't alleviate 
> the non-working
> -by- (NPI). Any ideas?
> 
> Regards,
> Lee
> 
> Lee Sieswerda, Epidemiologist
> Thunder Bay District Health Unit
> 999 Balmoral Street
> Thunder Bay, Ontario
> Canada  P7B 6E7
> Tel: +1 (807) 625-5957
> Fax: +1 (807) 623-2369
> Lee.Sieswerda@tbdhu.com
> www.tbdhu.com
> 
> *
> *   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/



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