Announcement

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

  • Sampling with different sampling rates from each strata

    Hello,
    I have a dataset from which I have to take a stratified sample in order to conduct a survey.
    I want to take different samples from each strata: e.g. 10% from strata A, 20% from strata B and 40% from strata C.
    I tried both the 'sample' command, as well as 'gsample', however it seems that using these commands the sampling rate has to be equal for all strata. Is this correct? How can I specify different sampling rates for each strata?

    Thanks,
    Kind regards,
    Mike

  • #2
    Here's an example of -gsample- doing what you want:
    Code:
     
    // example data
    clear
    set obs 10000
    gen int stratum = ceil(runiform() * 3)    
    gen int pct = stratum * 10  // for example
    //
    gsample pct, strata(stratum) gen(insample) wor percent
    tab insample stratum, col
    For a small demonstration of technique, here's the do-it-yourself approach:
    Code:
    gen pct .....
    gen rand = runiform()
    sort stratum rand
    by stratum: gen byte insample = (_n <=(_N * pct/100))

    Comment


    • #3
      From the helpfile for -gsample- (which, by the way is not official Stata and is available from SSC):

      gsample [#|varname] [if] [in] [weight] [, options]
      ...
      For stratified sampling, # units will be selected from each stratum identified by the strata() option. Alternatively, specify varname instead of #, where
      varname is a variable containing for each stratum a specific sample size. varname is assumed to be constant within strata.
      Added: Crossed with #2 who points out the same thing, in greater detail.

      Comment


      • #4
        Thanks a lot for your quick responses: I simply didn't realise that I could use a variable name instead of a number after the gsample command. Sorry for the inconvenience ...

        Comment


        • #5
          Thank you very much for all responses!

          Comment

          Working...
          X