Announcement

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

  • code for classifying participants based on complex criteria on a 9-item scale

    I'm looking for code to classify participants with depression using more complicated diagnostic criteria than I've used before with STATA.

    The scale is the 9-item PHQ 9. Each item (phq_1 through phq_9) has a value of 0 - 3.

    I need to identify participants based on meeting the following criteria:
    Major Depression: phq_1 or phq_2 of at least 2 AND at least five items phq_1 through phq_9 of at least 2. (But if phq_9 is 1 or higher, it counts towards the five items).

    Other Depression: phq_1 or phq_2 of at least 2 AND two, three, or four items phq_1 - phq_9 of at least 2. (Again, if phq_9 is 1 or higher, it counts towards the two, three or four items).

    I would really appreciate tips or code on how to express these criteria. I'm stuck at:
    gen mds = .
    replace mds = 1 if

    Thank you for any suggestions.

  • #2
    This is somewhat complicated and you need to create a few intermediate variables to work with before you can create your depression variables.

    Code:
    forvalues i = 1/9 {
        if `i' == 1 {
            gen endorsed_`i' = inrange(phq_`i', 1, 3)
        }
        else {
            gen endorsed_`i' = inrange(phq_`i', 2, 3)
        }
    }
    
    egen endorsements = rowtotal(endorsed_*)
    
    gen byte major_depression = max(phq_1, phq_2) >= 2 & endorsements >= 5
    gen byte other_depression = max(phq_1, phq_2) >= 2 & inrange(endorsements, 2, 4)

    Comment


    • #3
      Thank you so much, Clyde. I really appreciate the quick help.

      Comment

      Working...
      X