# Re: RE: RE: st: calculrating confidence Intervals in svypropstatements

 From To statalist@hsphsun2.harvard.edu Subject Re: RE: RE: st: calculrating confidence Intervals in svypropstatements Date Tue, 07 Sep 2004 11:22:52 -0400

```Dear Austin and other STATA Lister,

With your help, I calculated the scalar lcbs & ucbs for the nine est. props. The scalar lcbs & ucbs are the CIs themselves? They are too small numbers which do not include the point estimates, however. How can I get the appropriate CIs for my point estimates with the scalar lcbs and ucbs? Thanks for any suggestion for a novice STATA user.  All best, Hong

**** START
5 . svyprop  cat1Rr cat2Rr cat3Rr

Survey proportions estimation

+---------------------------------------------------------+
| cat1Rr   cat2Rr   cat3Rr   Obs   Est. Prop.   Std. Err. |
|---------------------------------------------------------|
|      0        0        0    65     0.202852    0.026513 |
|      0        0        1    29     0.078938    0.020018 |
|      0        1        0    13     0.028383    0.009759 |
|      0        1        1     2     0.003007    0.002141 |
|      1        0        0     5     0.005753    0.003897 |
|---------------------------------------------------------|
|      1        0        1     1     0.003676    0.003676 |
|      1        1        0     2     0.002165    0.001566 |
|      1        1        1     1     0.002011    0.002014 |
|      2        2        2   246     0.673215    0.031302 |
+---------------------------------------------------------+

6 . di "cat1Rr  cat2Rr  cat3Rr     (Lower Bound, Upper Bound)"
cat1Rr  cat2Rr  cat3Rr     (Lower Bound, Upper Bound)

7 . forvalues i=0/2 {
2. forvalues j=0/2 {
3. forvalues k=0/2 {
4. qui gen i`i'j`j'k`k'=(cat1Rr==`i' & cat2Rr==`j' & cat3Rr==`k')
5.  qui su i`i'j`j'k`k'
6.  if r(max)>0 & r(N)>0 {
7.   qui svylogit i`i'j`j'k`k'
8.   scalar lcb = invlogit(_b[_cons]-invttail(e(df_r),.025)*_se[_cons])
9.  scalar ucb = invlogit(_b[_cons]+invttail(e(df_r),.025)*_se[_cons])
10.  di "   `i'       `j'       `k'       ( " scalar(lcb) " , "scalar(ucb) " )
> "
11.   }
12.   }
13.   }
14.   }
0       0       0       ( .00203944 , .00360586 )
0       0       1       ( .00062643 , .00177758 )
0       1       0       ( .00019229 , .00074874 )
0       1       1       ( .00001 , .00016165 )
1       0       0       ( .0000204 , .00028998 )
1       0       1       ( 6.923e-06 , .00034891 )
1       1       0       ( 7.041e-06 , .00011894 )
1       1       1       ( 3.786e-06 , .00019084 )
2       2       2       ( .0076789 , .01054787 )

**** END

----- Original Message -----
From: "Nichols, Austin" <ANichols@ui.urban.org>
Date: Thursday, September 2, 2004 9:00 pm
Subject: RE: RE: st: calculrating confidence Intervals in svyprop statemen	ts

> Well, you've got a typo due to wrapping imposed by statalist.
> Lines 10 and
> 11 should be one line.  You should really read up ( -whelp egen-
> and -whelp
> tab- ) to figure out how to make a set of indicator variables, and
> then you
> can use -svyci- to get confidence intervals.
>
> Install svyci by typing
> net from http://www-personal.umich.edu/~nicholsa/stata
> net install svyci
>
> -----Original Message-----
> From: hk489@nyu.edu [hk489@nyu.edu]
> Sent: Thursday, September 02, 2004 8:35 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: RE: st: calculrating confidence Intervals in svyprop
> statements
>
>
> Dear Austin and other lister,
>
> I used the code from jpitblado@stata.com, which you let me know in
> youre-mail the other day. I believe I didn't make any
> typographical error, but
> STATA didn't calculate CIs and ended up with a caution message  (
> invalidname  r(199);.
>
> Below is the outputs:
>
>
> **** START
>
>    2. svyprop cat1Rr cat2Rr cat3Rr
>
>    Survey proportions estimation
>
>  +---------------------------------------------------------+
>  | cat1Rr   cat2Rr   cat3Rr   Obs   Est. Prop.   Std. Err. |
>  |---------------------------------------------------------|
>  |      0        0        0    65     0.202852    0.026513 |
>  |      0        0        1    29     0.078938    0.020018 |
>  |      0        1        0    13     0.028383    0.009759 |
>  |      0        1        1     2     0.003007    0.002141 |
>  |      1        0        0     5     0.005753    0.003897 |
>  |---------------------------------------------------------|
>  |      1        0        1     1     0.003676    0.003676 |
>  |      1        1        0     2     0.002165    0.001566 |
>  |      1        1        1     1     0.002011    0.002014 |
>  |      2        2        2   246     0.673215    0.031302 |
>  +---------------------------------------------------------+
>
>
>
>     3 . di "cat1Rr  cat2Rr  cat3Rr     (Lower Bound, Upper Bound)"
>      cat1Rr  cat2Rr  cat3Rr     (Lower Bound, Upper Bound)
>
>     4 . forvalues i=0/2 {
>        2. forvalues j=0/2 {
>        3. forvalues k=0/2 {
>        4. qui gen i`i'j`j'k`k'=(cat1Rr==`i' & cat2Rr==`j' &
> cat3Rr==`k')
>        5.    qui su i`i'j`j'k`k'
>        6.  if r(max)>0 & r(N)>0 {
>        7.  qui svylogit i`i'j`j'k`k'
>        8.  scalar lcb = invlogit(_b[_cons]-invttail(e(df_r),.025)*_se
> [_cons])
>        9. scalar ucb =
> invlogit(_b[_cons]+invttail(e(df_r),.025)*_se[_cons])
>       10.  di "   `i'       `j'       `k'       ( " scalar(lcb) "
> , "
>       11. scalar(ucb) " )"
>       12. }
>       13. }
>       14. }
>       15. }
>         0       0       0       ( .00203944 ,
>      ( invalid name
>      r(199);
> *** END
>
>
> Did I make any mistake? Any suggestion?  Many thanks for your
> invaluablehelp to a novice STATA user.   Hong
>
>
>
>
>
>
>
>
>
> ----- Original Message -----
> From: "Nichols, Austin" <ANichols@ui.urban.org>
> Date: Wednesday, September 1, 2004 6:16 pm
> Subject: RE: st: calculrating confidence Intervals in svyprop
> statements
> > Note that you report nine categories, and I don't think your CIs
> > will be
> > plausible, given the number of obs and apparent weighting and
> > survey design.
> > Plus your categories are suspect, since if they were 0/2 you
> would
> > have 27
> > categories instead of nine. But mine is not to reason why. Using
> > code from
> >
> > di "cat1Rr  cat2Rr  cat3Rr     (Lower Bound, Upper Bound)"
> > forvalues i=0/2 {
> > forvalues j=0/2 {
> >  forvalues k=0/2 {
> >    qui gen i`i'j`j'k`k'=(cat1Rr==`i' & cat2Rr==`j' &
> cat3Rr==`k')
> >    qui su i`i'j`j'k`k'
> >    if r(max)>0 & r(N)>0 {
> >        qui svylogit i`i'j`j'k`k'
> >        scalar lcb = invlogit(_b[_cons]-
> > invttail(e(df_r),.025)*_se[_cons])        scalar ucb =
> > invlogit(_b[_cons]+invttail(e(df_r),.025)*_se[_cons])        di
> "
> > `i'       `j'       `k'       ( " scalar(lcb) " , "
> > scalar(ucb) " )"
> >    }
> >  }
> > }
> > }
> >
> > gives CIs that are constructed independently and cannot be used to
> > eyeball-test joint hypotheses about proportions. Caveat emptor.
> >

*
*   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/
```