Announcement

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

  • svyset subpop

    Hi there,

    I am currently working on a secondary analysis of survey data, where only a subpopulation of the whole sample are eligible for inclusion in my analysis.

    I have created a dummy variable in Stata to identify eligible observations, where 1 = eligible & 0 = non-eligible.

    I have used the syvset command to inform Stata of the survey sample design: 'svyset w1psu [pweight = b_ind5mus_lw], strata(w1strata) singleunit(centered)'
    However, when I attempt to use the subpop option after svy to obtain descriptive statistics, my sample size for the subpopulation is incorrect. For example, I would like to obtain the mean age for my subpopulation and used the following code - 'svy, subpop(completecase_DF): mean w1age_dv'. See output below:

    Survey: Mean estimation

    Number of strata = 470 Number of obs = 1,297
    Number of PSUs = 1,065 Population size = 164.539813
    Subpop. no. obs = 967
    Subpop. size = 131.303466
    Design df = 595

    --------------------------------------------------------------
    | Linearized
    | Mean std. err. [95% conf. interval]
    -------------+------------------------------------------------
    w1age_dv | 38.45084 1.580497 35.34681 41.55487
    --------------------------------------------------------------
    Note: 71 strata omitted because they contain no subpopulation
    members.
    Note: Strata with single sampling unit centered at overall
    mean.

    subpop no. obs states my sample size is 967, however the sample size is 968. There is no missing data in the age variable so I unsure why the observation number is 1 less than expected.

    Any information/guidance anyone can provide on why this may be the case would be really appreciated.


  • #2
    Evie:
    what if you investigate the issue via -e(sample)-?:
    Code:
    . use https://www.stata-press.com/data/r18/nhanes2d.dta
    
    
    . svyset tcresult [pweight = houssiz ], strata( race )
    
    Sampling weights: houssiz
                 VCE: linearized
         Single unit: missing
    
    . svy: mean tcresult 
    
    
    Survey: Mean estimation
    
    Number of strata =   3                Number of obs   = 10,351
    Number of PSUs   = 650                Population size = 30,471
                                          Design df       =    647
    
    --------------------------------------------------------------
                 |             Linearized
                 |       Mean   std. err.     [95% conf. interval]
    -------------+------------------------------------------------
        tcresult |   214.2615    2.32959       209.687     218.836
    --------------------------------------------------------------
    
    . g sample=e(sample)
    
    . tab sample
    
         sample |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              1 |     10,351      100.00      100.00
    ------------+-----------------------------------
          Total |     10,351      100.00
    
    .
    The observations with -e(sample)-=1 are included in your estimate, 0 othertwise.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Might the subpopulation include an observation where the weight variable is zero or missing?

      Added: Crossed with #2. Following up on Carlo Lazzaro 's excellent suggestion, if you run:
      Code:
      browse if completecase_DF & !e(sample)
      Stata will show you the observation that is omitted from your analysis despite having completecase_DF non-zero. You can then inspect it to see what about it may be causing the problem.
      Last edited by Clyde Schechter; 05 Feb 2025, 11:20.

      Comment


      • #4
        Hi Carlo and Cylde,

        Thank you so much for your helpful suggestions!

        I have used ' g sample=e(sample)
        tab sample' which has given me the below output:

        sample | Freq. Percent Cum.
        ------------+-----------------------------------
        0 | 37,067 96.62 96.62
        1 | 1,297 3.38 100.00
        ------------+-----------------------------------
        Total | 38,364 100.00


        I am confused by this result for two reasons: firstly it appears the e(sample) command suggests that the full sample (Number of obs = 1,297) has been used to calculate my mean and not the subsample (Subpop. no. obs = 967), and secondly I am not sure why the number of obvs for the full sample would be 1297, as the number of observations who have data for the subgrouping variable (completecase_DF) is 1,4001 - see below.

        tab completecase_DF

        completecase_ |
        DF | Freq. Percent Cum.
        --------------+-----------------------------------
        missing case | 433 30.91 30.91
        complete case | 968 69.09 100.00
        --------------+-----------------------------------
        Total | 1,401 100.00


        If either of you have any further guidance it would be greatly appreciated.

        Many thanks

        Comment


        • #5
          Further to this, Clyde you were correct about the weighting. One of the observations in my subpopulation has a weighting of 0, which would explain why my sample size is showing as 1 below what it should be. However, I still cannot explain the 1297 figure

          Comment


          • #6
            In svy estimation, e(sample) counts any observation used in the estimation, not just the subpopulation of interest. Out of subpopulation observations can contribute to variance estimation (VCE) -- as zero values -- and are thus counted in the design degrees of freedom.

            Also, the output from svy: mean contains the note
            Code:
            Note: 71 strata omitted because they contain no subpopulation
            members.
            This means all observations in these omitted strata are dropped from the estimation sample, i.e. they are not used in the VCE or counted for the design degrees of freedom.

            Comment


            • #7
              Hi Jeff,

              Thanks so much for your response.

              So essentially, in my full sample I have both eligible and non-eligible observations in different stratas, then when I choose to analyse only eligible observations (my subpopulation) the stratas that only contain non-eligible observations are omitted - is my understanding correct?

              Comment


              • #8
                Yes

                Comment

                Working...
                X