Announcement

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

  • proportions, new variable??

    Dear All
    I am trying to get a proportion values with my data, but I am not sure if I need to generate new variables. In summary I want the proportion of single prolapse means when only one of the scallop is positive (PA1 or PA2 or PA3 or PP1 or PP2 or PP3 are =1), bileaflet prolpase (when PA1 or PA2 or PA3 are present (=1) & PP1 or PP2 or PP3 are also present, and multiple scallop prolapse when there are more than one scallop positive independiently if belong to leaflet A or P, eg PA1=1 and PA2=1 or PA3=1 and PP1=1 etc..


    dataex PA1 PA2 PA3 PP1 PP2 PP3

    Code:
    clear
    input byte(PA1 PA2 PA3 PP1 PP2 PP3)
    0 1 1 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 1 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 1 1 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 1 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 0 1 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 1 0 0 
    0 0 0 1 0 0 
    0 0 0 1 0 0 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 1 0 0 1 1 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 1 0 0 0 0 
    0 0 0 1 0 0 
    0 0 0 1 0 0 
    0 1 0 0 0 0 
    0 1 0 0 0 0 
    0 1 0 0 0 0 
    0 0 0 1 1 0 
    0 0 0 0 1 0 
    1 1 1 1 1 1 
    0 0 0 0 0 1 
    1 0 0 1 0 0 
    0 1 0 0 1 0 
    0 0 0 0 0 1 
    0 0 0 0 1 0 
    0 1 1 0 1 1 
    0 0 0 0 0 0 
    0 1 0 0 0 0 
    0 0 0 0 0 0 
    1 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    0 0 0 0 1 0 
    1 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 1 0 
    0 0 0 0 0 0 
    0 1 0 0 1 0 
    0 0 0 1 0 0 
    0 0 0 0 1 0 
    0 0 1 0 0 1 
    0 0 0 0 1 0 
    0 0 0 1 1 0 
    0 0 0 1 0 0 
    0 0 0 0 0 1 
    end
    label def Detectado 0 "No", modify
    label def Detectado 1 "Si", modify
    label values PA1 Detectado
    label def Detectado 0 "No", modify
    label def Detectado 1 "Si", modify
    label values PA2 Detectado
    label def Detectado 0 "No", modify
    label def Detectado 1 "Si", modify
    label values PA3 Detectado
    label def Detectado 0 "No", modify
    label def Detectado 1 "Si", modify
    label values PP1 Detectado
    label def Detectado 0 "No", modify
    label def Detectado 1 "Si", modify
    label values PP2 Detectado
    label def Detectado 0 "No", modify
    label def Detectado 1 "Si", modify
    label values PP3 Detectado

  • #2
    First, note that the value labels can be defined much smarter
    Code:
    label define Detectado 0 "No" 1 "Si"
    label values PA1-PP2 Detectado
    Next, characterize each patient by number of PAs and PPs and the total number. The following tables give most of the answer.
    Code:
    gen sumPA = PA1+PA2+PA3
    gen sumPP = PP1+PP2+PP3
    gen sumPAPP = sumPA + sumPP
    
    . tab1 sumPAPP
    
    -> tabulation of sumPAPP  
    
        sumPAPP |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              0 |         18       20.00       20.00
              1 |         61       67.78       87.78
              2 |          8        8.89       96.67
              3 |          1        1.11       97.78
              4 |          1        1.11       98.89
              6 |          1        1.11      100.00
    ------------+-----------------------------------
          Total |         90      100.00
    
    . tab2 sumPA sumPP
    
    -> tabulation of sumPA by sumPP  
    
               |                    sumPP
         sumPA |         0          1          2          3 |     Total
    -----------+--------------------------------------------+----------
             0 |        18         52          3          0 |        73 
             1 |         9          4          1          0 |        14 
             2 |         1          0          1          0 |         2 
             3 |         0          0          0          1 |         1 
    -----------+--------------------------------------------+----------
         Total |        28         56          5          1 |        90
    This may not be exactly what you need, but it may help you on the way.

    Comment


    • #3
      Dear Svend, any help is very welcome, thank you so much for your answer, I will check now how to do it

      Comment


      • #4
        Dear Ana,
        I think that you can solve what you want with this code:
        Code:
        egen single_prolapse=rowmax(PA1-PP3)
        egen PA=rowmax(PA1-PA3)
        egen PP=rowmax(PP1-PP3)
        egen bileaflet_prolapse=rowmin(PA PP)
        egen PS=rowtotal(PA1-PP3)
        gen multiple_prolapse=PS>1
        proportion single_prolapse bileaflet_prolapse multiple_prolapse
        I hope this helps you,
        Modesto

        Comment


        • #5
          Scallop? Polyp? ???

          Comment


          • #6
            Working well Modesto, thank you so much.

            Comment


            • #7
              Ana something is bothering me. You defined single prolapse as ONLY ONE of the options being possible. If this is the case then Modesto's generation of the single_prolapse is not correct. To illustrate check the following:
              Code:
              clear all 
              set more off
              input byte(PA1 PA2 PA3 PP1 PP2 PP3)
              0 1 1 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 1 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 1 1 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 1 0 0 0 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 0 1 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 1 0 0 
              0 0 0 1 0 0 
              0 0 0 1 0 0 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 1 0 0 1 1 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 1 0 0 0 0 
              0 0 0 1 0 0 
              0 0 0 1 0 0 
              0 1 0 0 0 0 
              0 1 0 0 0 0 
              0 1 0 0 0 0 
              0 0 0 1 1 0 
              0 0 0 0 1 0 
              1 1 1 1 1 1 
              0 0 0 0 0 1 
              1 0 0 1 0 0 
              0 1 0 0 1 0 
              0 0 0 0 0 1 
              0 0 0 0 1 0 
              0 1 1 0 1 1 
              0 0 0 0 0 0 
              0 1 0 0 0 0 
              0 0 0 0 0 0 
              1 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              0 0 0 0 1 0 
              1 0 0 0 0 0 
              0 0 0 0 0 0 
              0 0 0 0 0 0 
              0 0 0 0 1 0 
              0 0 0 0 0 0 
              0 1 0 0 1 0 
              0 0 0 1 0 0 
              0 0 0 0 1 0 
              0 0 1 0 0 1 
              0 0 0 0 1 0 
              0 0 0 1 1 0 
              0 0 0 1 0 0 
              0 0 0 0 0 1
              end
              
              egen single_prolapse=rowmax(PA1-PP3)
              l in 1/2
              You will find that for the first row you have two options that are 1, so single_prolapse ought to be zero, yet according to the code it's one. Following Modesto's elegant use of egen
              Code:
              egen PS = rowtotal(PA1-PP3)
              gen multiple_prolapse = PS >1
              gen single_prolapse = 1 - multiple_prolapse
              In reality you only need to generate one of the two (single or multiple) since by definition the proportion of one is just 1 minus the proportion of the other.

              All the best
              Alfonso Sanchez-Penalver

              Comment


              • #8
                Thank you Alfonso for clarify, you are right, single prolapse means only one of the 6 scallops is involved, and multiple means more than one independently if are belong to anterior (PA1,PA2,PA3) and/or posterior leaflets (PP1,PP2,PP3) , however bileaflet means more than one but both leaflets must be affected (e.g PA1 & PP1, or PA2 & PP2 & PP3....), at the same time means also multiple because there will be always more than one

                Comment


                • #9
                  Yes in other words a bileaflet is always a multiple prolapse but not all multiple prolapses are bileaflets because they can be singleleaflets like the first observation in the data you sent us. The code Modesto has for bileaflets works well. Glad to help.
                  Alfonso Sanchez-Penalver

                  Comment


                  • #10
                    Hi Ana and Alfonso!
                    Alfonso was right. I looked at the formula: (PA1 or PA2 or PA3 or PP1 or PP2 or PP3 are =1) while Alfonso realized properly that single means that "only one of the scallop is positive". Thanks.
                    All the best.

                    Comment


                    • #11
                      Thanks (Muchas Gracias) Modesto & Alfonso, very helpful!!
                      Kind regards

                      Comment

                      Working...
                      X