Announcement

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

  • Scoring measures using STATA

    I have dataset that includes items measuring diagnostic criteria for personality disorders. For each criterion there are multiple items. For some of the criteria, respondents must respond yes to more than two items in order to meet that criterion. A criterion may have 5 items and thus multiple combinations of items would satisfy that criterion. Does anyone have experience scoring measures using Stata? Is there a way to include multiple combinations of items in an "if" statement without list all combinations? Please let me know if any of this is unclear.

  • #2
    It may just be me, but your question is indeed unclear to me. And any answer would depend crucially on what your data are like.

    You should take the time to review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

    The common language we all share, regardless of our background, is that of "Data and Stata", which is why presenting realistic data (even if "faked" to meet confidentiality concerns) and potential Stata code is often more helpful than an abstract discussion.

    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Comment


    • #3
      I appreciate you responding and hope the following is clearer.
      I have variables related to items on a measure of personality disorders. For example, var1 = "did you ever vandalize another's property?" (0=no, 1=yes), var2 = "did you ever start a fire intentionally?" (0=no, 1=yes), var3 = "did you ever shoplift" (0=no, 1=yes), etc. These and 6 other items measure the criterion "failure to conform to norms". One must answer yes to at least two of these questions to qualify for this criterion.
      I would like to create a variable for this criterion that represents whether they said yes to at least two of these items.

      Comment


      • #4
        Assuming you have no missing values in your data, so that each of your 9 variables is either 0 or 1, the sum of the variables in the first command below tells you how many they responded yes to, and the expression in the second command will be 1 if that number is at least 2 and 0 otherwise.
        Code:
        generate num_yes = var1 + var2 + var3 + var4 + var5 + var6 + var7 + var8 + var9
        generate criterion = num_yes>=2

        Comment


        • #5
          Thank you very much!

          Comment


          • #6
            This crossed with William's answer, but since I use a slightly different approach, I thought I would post it anyway.

            Code:
            * Example generated by -dataex-. To install: ssc install dataex
            clear
            input byte(id v1 v2 v3 v4 v5 v6)
             1 1 0 0 0 1 1
             2 0 0 0 1 1 1
             3 1 0 0 1 0 1
             4 0 0 0 1 0 0
             5 0 0 0 0 0 0
             6 1 1 1 0 0 1
             7 1 0 1 1 1 1
             8 1 0 0 1 0 0
             9 0 1 0 0 0 1
            10 1 0 1 1 1 0
            11 1 0 1 0 1 1
            12 0 0 1 0 0 0
            end
            Code:
            egen count = rowtotal(v1-v6)
            gen has_disorder = (count >=2)  // this is the same as William's answer
            
            * Loop to create all-in-one list of which questions they answered "yes"
            gen which_questions = "1, " if v1 == 1
            
            forvalues i = 2/6 {
            replace which_questions = which_questions + "`i', " if v`i'==1
            }
            
            . list, noobs abbrev(16)
            
              +---------------------------------------------------------------------------+
              | id   v1   v2   v3   v4   v5   v6   count   has_disorder   which_questions |
              |---------------------------------------------------------------------------|
              |  1    1    0    0    0    1    1       3              1         1, 5, 6,  |
              |  2    0    0    0    1    1    1       3              1         4, 5, 6,  |
              |  3    1    0    0    1    0    1       3              1         1, 4, 6,  |
              |  4    0    0    0    1    0    0       1              0               4,  |
              |  5    0    0    0    0    0    0       0              0                   |
              |---------------------------------------------------------------------------|
              |  6    1    1    1    0    0    1       4              1      1, 2, 3, 6,  |
              |  7    1    0    1    1    1    1       5              1   1, 3, 4, 5, 6,  |
              |  8    1    0    0    1    0    0       2              1            1, 4,  |
              |  9    0    1    0    0    0    1       2              1            2, 6,  |
              | 10    1    0    1    1    1    0       4              1      1, 3, 4, 5,  |
              |---------------------------------------------------------------------------|
              | 11    1    0    1    0    1    1       4              1      1, 3, 5, 6,  |
              | 12    0    0    1    0    0    0       1              0               3,  |
              +---------------------------------------------------------------------------+
            
            * To get rid of comma and space at the very end
            replace which_questions = substr(which_questions, 1, strlen(which_questions) - 2) if substr(which_questions, -2, .)==", " 
            
            . list, noobs abbrev(16)
            
              +---------------------------------------------------------------------------+
              | id   v1   v2   v3   v4   v5   v6   count   has_disorder   which_questions |
              |---------------------------------------------------------------------------|
              |  1    1    0    0    0    1    1       3              1           1, 5, 6 |
              |  2    0    0    0    1    1    1       3              1           4, 5, 6 |
              |  3    1    0    0    1    0    1       3              1           1, 4, 6 |
              |  4    0    0    0    1    0    0       1              0                 4 |
              |  5    0    0    0    0    0    0       0              0                   |
              |---------------------------------------------------------------------------|
              |  6    1    1    1    0    0    1       4              1        1, 2, 3, 6 |
              |  7    1    0    1    1    1    1       5              1     1, 3, 4, 5, 6 |
              |  8    1    0    0    1    0    0       2              1              1, 4 |
              |  9    0    1    0    0    0    1       2              1              2, 6 |
              | 10    1    0    1    1    1    0       4              1        1, 3, 4, 5 |
              |---------------------------------------------------------------------------|
              | 11    1    0    1    0    1    1       4              1        1, 3, 5, 6 |
              | 12    0    0    1    0    0    0       1              0                 3 |
              +---------------------------------------------------------------------------+

            Comment


            • #7
              Here are some other techniques, stealing david Benson's helpful data example.

              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input byte(id v1 v2 v3 v4 v5 v6)
               1 1 0 0 0 1 1
               2 0 0 0 1 1 1
               3 1 0 0 1 0 1
               4 0 0 0 1 0 0
               5 0 0 0 0 0 0
               6 1 1 1 0 0 1
               7 1 0 1 1 1 1
               8 1 0 0 1 0 0
               9 0 1 0 0 0 1
              10 1 0 1 1 1 0
              11 1 0 1 0 1 1
              12 0 0 1 0 0 0
              end
              
              egen all = concat(v*) 
              
              gen count1 = length(all) - length(subinstr(all, "0", "", .)) 
              
              gen which1 = "" 
              quietly forval j = 1/6 { 
                  replace which1 = which1 + "`j'" if v`j' 
              }
              
              list, sep(0) 
              
                   +-------------------------------------------------------------+
                   | id   v1   v2   v3   v4   v5   v6      all   count1   which1 |
                   |-------------------------------------------------------------|
                1. |  1    1    0    0    0    1    1   100011        3      156 |
                2. |  2    0    0    0    1    1    1   000111        3      456 |
                3. |  3    1    0    0    1    0    1   100101        3      146 |
                4. |  4    0    0    0    1    0    0   000100        5        4 |
                5. |  5    0    0    0    0    0    0   000000        6          |
                6. |  6    1    1    1    0    0    1   111001        2     1236 |
                7. |  7    1    0    1    1    1    1   101111        1    13456 |
                8. |  8    1    0    0    1    0    0   100100        4       14 |
                9. |  9    0    1    0    0    0    1   010001        4       26 |
               10. | 10    1    0    1    1    1    0   101110        2     1345 |
               11. | 11    1    0    1    0    1    1   101011        2     1356 |
               12. | 12    0    0    1    0    0    0   001000        5        3 |
                   +-------------------------------------------------------------+

              Comment


              • #8
                Thank you all very much!

                Comment

                Working...
                X