Announcement

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

  • Using svy: prop and lincom to test change in percentages

    Hello All,
    I am looking at data from consecutive surveys to look for changes in different indicators over time. I read this paper (https://malariajournal.biomedcentral...936-017-1946-1) and thus started to follow the same method using svy: prop and then lincom command to find the difference in percentages and get the CIs around those differences.
    The problem I have is that the svy: prop command gives the same point estimates that I calculated previously using svy: tab command, but the CIs around the estimates are different and sometimes go into the negative, much like the problem previously posted here: https://www.stata.com/statalist/arch.../msg01127.html

    From that post I can see the the svy: tab is giving me the best point estimates and CIs for my indicators, but can I use these values for the indicator values in each survey and then use the lincom with svy: prop to get accurate percentage difference values?

    e.g.:
    svy: tab seek_treat survey if fever==1, per col ci obs format (%6.2f) ///take point estimates and CIs from here for each survey
    svy: prop seek_treat if fever==1, over(survey)
    lincom _b[yes:2] - _b[yes:1] ////and take difference in %s from here
    lincom _b[yes:3] - _b[yes:1]


    Thank you, Hannah



  • #2
    Still hoping for clarification on this if anyone can help. Thanks!

    Comment


    • #3
      I see that you have been a Statalist member for over a year. When you registered you apparently skipped the suggestion to read the Statalist FAQ "Advice on Posting", https://www.statalist.org/forums/help. To me, the most important directives are in 12.1, 12.2, and 12.3,

      12.1 "Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!" For survey data, I suggest that you start with your svyset command.

      12.2 Provide an illustrative data set that we can use to demonstrate approaches to your problem. Best is an extract of your own data, created with Robert Picard and Nick Cox's command dataex, available at SSC
      Code:
       ssc install dataex
      12.3 Enclose commands and results in CODE blocks, formed by CODE delimiters.( I just did that to get the block above.) I suggest that you practice in the Sandbox Forum. I often test my posts there before submitting them here. Pressing the "A", the middle one of the three boxes to the upper right will expose a lot of other formatting commands.

      Aside: I notice that you subsetted to "fever = 1" with an if restriction. To quote the help for svy:
      Warning: Using if or in restrictions will often not produce correct variance estimates for subpopulations. To compute estimates for subpopulations, use the subpop() option
      Last edited by Steve Samuels; 15 Sep 2017, 19:17.
      Steve Samuels
      Statistical Consulting
      [email protected]

      Stata 14.2

      Comment


      • #4
        Well, I still don't understand your question. In particular what you mean by
        .. can I use these values for the indicator values in each survey?
        Only an illustration with your data, as the FAQ ask for, would help. However here are illustrations of what appears to be your problem with svy tab and svy prop. Note that standard errors from svy tab and svy prop are identical and that standard errors and CIs from the two lincoms are identical.

        Code:
        sysuse auto, clear
        rename rep78 group
        recode group  1/3 = 1 4=2 5 = 3
        svyset _n
        
        /* svy tab */
        svy, subpop(if mpg>22): tab foreign group, col se ci
        matrix list e(b)   // identify coefficients
        lincom _b[p11] -_b[p12]
        
        /* svy prop */
        svy, subpop(if mpg>22): prop foreign, over(group)
        /* Use coeflegend to see names of coefficients */
        svy, subpop(if mpg>22) : prop foreign, over(group) coeflegend
        lincom _b[Domestic:1] -_b[Domestic:2]
        with results
        Code:
        . . sysuse auto, clear
        (1978 Automobile Data)
        
        . rename rep78 group
        
        . recode group  1/3 = 1 4=2 5 = 3
        (group: 67 changes made)
        
        . svyset _n
        
              pweight: <none>
                  VCE: linearized
          Single unit: missing
             Strata 1: <one>
                 SU 1: <observations>
                FPC 1: <zero>
        
        .
        . /* svy tab */
        . svy, subpop(if mpg>22): tab foreign group, col se ci
        (running tabulate on estimation sample)
        
        Number of strata   =         1                  Number of obs     =         72
        Number of PSUs     =        72                  Population size   =         72
                                                        Subpop. no. obs   =         24
                                                        Subpop. size      =         24
                                                        Design df         =         71
        
        ----------------------------------------------------------------------
                  |                     Repair Record 1978                    
         Car type |             1              2              3          Total
        ----------+-----------------------------------------------------------
         Domestic |           .75          .1111          .2857           .375
                  |       (.1542)        (.1055)        (.1719)        (.0995)
                  |  [.368,.9392]  [.0146,.5126]  [.0694,.6821]  [.2047,.5832]
                  |
          Foreign |           .25          .8889          .7143           .625
                  |       (.1542)        (.1055)        (.1719)        (.0995)
                  |  [.0608,.632]  [.4874,.9854]  [.3179,.9306]  [.4168,.7953]
                  |
            Total |             1              1              1              1
                  |                                                          
                  |                                                          
        ----------------------------------------------------------------------
          Key:  column proportion
                (linearized standard error of column proportion)
                [95% confidence interval for column proportion]
        
          Pearson:
            Uncorrected   chi2(2)         =   23.1365
            Design-based  F(2.00, 142.00) =    3.8025     P = 0.0246
        
        . matrix list e(b)   // identify coefficients
        
        e(b)[1,6]
                  p11        p12        p13        p21        p22        p23
        y1        .75  .11111111  .28571429        .25  .88888889  .71428571
        
        . lincom _b[p11] -_b[p12]
        
         ( 1)  p11 - p12 = 0
        
        ------------------------------------------------------------------------------
               Ratio |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                 (1) |   .6388889    .186805     3.42   0.001     .2664103    1.011367
        ------------------------------------------------------------------------------
        
        .
        . /* svy prop */
        . svy, subpop(if mpg>22): prop foreign, over(group)
        (running proportion on estimation sample)
        
        Survey: Proportion estimation
        
        Number of strata =       1        Number of obs   =         72
        Number of PSUs   =      72        Population size =         72
                                          Subpop. no. obs =         24
                                          Subpop. size    =         24
                                          Design df       =         71
        
             Domestic: foreign = Domestic
              Foreign: foreign = Foreign
        
                    1: group = 1
                    2: group = 2
                    3: group = 3
        
        --------------------------------------------------------------
                     |             Linearized
                Over | Proportion   Std. Err.     [95% Conf. Interval]
        -------------+------------------------------------------------
        Domestic     |
                   1 |        .75   .1541675      .3679874    .9392369
                   2 |   .1111111   .1054917       .014641    .5125714
                   3 |   .2857143   .1719452      .0693801    .6821498
        -------------+------------------------------------------------
        Foreign      |
                   1 |        .25   .1541675      .0607631    .6320126
                   2 |   .8888889   .1054917      .4874286     .985359
                   3 |   .7142857   .1719452      .3178502    .9306199
        --------------------------------------------------------------
        
        . /* Use coeflegend to see names of coefficients */
        . svy, subpop(if mpg>22) : prop foreign, over(group) coeflegend
        (running proportion on estimation sample)
        
        Survey: Proportion estimation
        
        Number of strata =       1        Number of obs   =         72
        Number of PSUs   =      72        Population size =         72
                                          Subpop. no. obs =         24
                                          Subpop. size    =         24
                                          Design df       =         71
        
             Domestic: foreign = Domestic
              Foreign: foreign = Foreign
        
                    1: group = 1
                    2: group = 2
                    3: group = 3
        
        ------------------------------------------------------------------------------
                Over | Proportion  Legend
        -------------+----------------------------------------------------------------
        Domestic     |
                   1 |        .75  _b[Domestic:1]
                   2 |   .1111111  _b[Domestic:2]
                   3 |   .2857143  _b[Domestic:3]
        -------------+----------------------------------------------------------------
        Foreign      |
                   1 |        .25  _b[Foreign:1]
                   2 |   .8888889  _b[Foreign:2]
                   3 |   .7142857  _b[Foreign:3]
        ------------------------------------------------------------------------------
        
        . lincom _b[Domestic:1] -_b[Domestic:2]
        
         ( 1)  [Domestic]1 - [Domestic]2 = 0
        
        ------------------------------------------------------------------------------
          Proportion |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                 (1) |   .6388889    .186805     3.42   0.001     .2664103    1.011367
        ------------------------------------------------------------------------------
        .
        .
        Steve Samuels
        Statistical Consulting
        [email protected]

        Stata 14.2

        Comment

        Working...
        X