Announcement

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

  • Question wtih regards to STTOCC Function

    Hi,

    I am sampling patients for matched cohort study using the STTOCC function. I understand that since this function is for case-control studies, there is sampling with replacement.

    Is it possible to select non-exposed (or control) patients without replacements using STTOCC or a similar function?

    Thank you,
    Kevin

  • #2
    Bumping this post for visibility at the top. Kevin.

    Comment


    • #3
      Here's one way to do this that occurs to me:
      Code:
      // Create example files of cases and controls to work with, with nvars to match on
      clear
      set seed 33245
      local nvars = 4
      local ncases = 100
      set obs 1000
      //
      gen int id = _n
      gen byte case = _n <= `ncases'
      forval i = 1/`nvars'{
        gen x`i' = ceil(3*runiform())  // x* are the variables on which cases and controls will be exactly matched
      }
      // Separate files of cases and controls, as I presume they are in the real situation
      preserve
      tempfile cases controls
      keep if case == 1
      tempfile cases
      save `cases', replace
      restore
      keep if case == 0
      rename id controlid
      save `controls'
      // End of preparing example data
      //
      ****************************************************
      //
      // Real data situation would start here.
      //  Prep controls: Randomly order the controls who share the vector of x* values.
      use `controls', clear
      set seed 9432 
      gen rand = runiform() // random sequence number for matching
      sort x* rand
      by x*: gen int seqnum = _n
      drop rand
      tempfile controls
      save `controls'
      //
      // Match controls to cases by x* and seqnum.
      use `cases'
      gen rand = runiform()
      sort x* rand // Ensures that any case w/o available match will be randomly chosen
      by x*: gen int seqnum = _n
      merge 1:1 x* seqnum using `controls', keep(3)

      An incidental comment: I am not familiar with -sttocc-, but I don't see why its' being intended for case control studies would necessitate sampling with replacement.

      Regards, Mike

      Comment

      Working...
      X