Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • manual calculation of CIs for with svy command

    Hi All

    I am trying to compute confidence interval after running a survey proportion using e(b) and e(V). However, I cant match the confidence interval presented in the output. Here is what i am doing:

    svy: prop hb_anaemia t if state==28
    (running proportion on estimation sample)

    Survey: Proportion estimation

    Number of strata = 1 Number of obs = 401
    Number of PSUs = 60 Population size = 404.05598
    Design df = 59

    _prop_1: hb_anaemia = Non-anaemic

    --------------------------------------------------------------
    | Linearized Logit
    | Proportion Std. Err. [95% Conf. Interval]
    -------------+------------------------------------------------
    hb_anaemia |
    _prop_1 | .6042869 .0454942 .5106642 .6908414
    Anaemic | .3957131 .0454942 .3091586 .4893358
    -------------+------------------------------------------------
    t |
    1 | 1 . . .
    --------------------------------------------------------------

    . matrix b = e(b)

    . matrix v = e(V)

    . scalar bound = sqrt(v[2,2])*invttail(e(df_r),0.025)

    .
    . scalar ll = b[1,2]-bound

    . scalar ul = b[1,2]+bound

    .
    . di ll
    .30467944

    . di ul
    .48674686

    As you can see for Anaemic, the lower bound is 0.30467944 as per my manual calculation, whereas it is 0.3091586 as per STATA's internal calculation and presented in the table. Same problem with upper bound. Am I missing something here? Why am I not getting the same CIs ? Will really appreciate your help.

    Rajib




  • #2
    Your calculation is not what Stata does to get the CI of a proportion. The CI for a proportion is calculated by finding a CI for the logit of the proportion, than back-transforming. This keeps the confidence intervals for the proportion within the bounds of 0 and 1. Fpr details, see the Methods and Formulas section of the Manual entry for the proportion command.
    Last edited by Steve Samuels; 09 May 2018, 19:43.
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment


    • #3
      Originally posted by Steve Samuels View Post
      Your calculation is not what Stata does to get the CI of a proportion. The CI for a proportion is calculated by finding a CI for the logit of the proportion, than back-transforming. This keeps the confidence intervals for the proportion within the bounds of 0 and 1. Fpr details, see the Methods and Formulas section of the Manual entry for the proportion command.
      Dear Steve

      Many thanks. I have realised that. However, to take the CI to an excel worksheet (using puexcel) i need to manually calculate it. So, I need a formula or sort for this. Can you help me with that? My main aim is to bring the CIs to my excel table, which is pre-fixed. I was hoping to compute CIs using e(b) and e(V) and bring them to the table through putexcel.

      Do you suggest any other method?

      Many thanks again for your help.

      Comment


      • #4
        I'm not sure what your problem is. In the final formula for the CI in the manual, the \(\widehat{p}\) and \(\widehat{s}\) terms are, respectively, an element of e(b) and the square root of a diagonal element of e(V). You could the results in a matrix and, according to the manual, export them with putexcel. As I never use that command, I can't help you any further.

        Added: More simply, the confidence limits are available without additional calculation in the returned matrix r(table). putexcel can export r(table) or any submatrix of r(table)
        Last edited by Steve Samuels; 10 May 2018, 14:37.
        Steve Samuels
        Statistical Consulting
        [email protected]

        Stata 14.2

        Comment


        • #5
          Steve! You saved my life! Thanks a million! I am using r(table)

          Comment

          Working...
          X