Announcement

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

  • Mann Whitney test

    Hi trying to do a Mann Whitney test - used the code as seen below:

    ranksum Newtreadmill, by(Fitbit) porder exact

    The following error came up:
    more than 2 groups found, only 2 allowed
    r(499);

    I am only using 2 groups....


    CODE]
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(Fitbit Newtreadmill)
    645 602
    658 636
    717 692
    691 709
    730 654
    end
    [/CODE]

  • #2
    In your data example Fitbit takes on accettala distinct values. The by group Missy be coded as 0 and 1, two groups. Try an example from the manual to see this.

    Comment


    • #3
      try the following which first renames your variables so they can be used in -reshape-, then reshapes the data so it can be used for -ranksum-; note that I have not put labels on "count" but you can label them as Fitbit and as Newtreadmill:
      Code:
      . ren Fitbit ex1
      r; t=0.13 9:52:23
      
      . ren Newtreadmill ex2
      r; t=0.00 9:52:34
      
      . reshape long ex, i(id) j(count)
      (j = 1 2)
      
      Data                               Wide   ->   Long
      -----------------------------------------------------------------------------
      Number of observations                5   ->   10          
      Number of variables                   3   ->   3           
      j variable (2 values)                     ->   count
      xij variables:
                                      ex1 ex2   ->   ex
      -----------------------------------------------------------------------------
      
      . ranksum ex, by(count) porder
      
      Two-sample Wilcoxon rank-sum (Mann–Whitney) test
      
             count |      Obs    Rank sum    Expected
      -------------+---------------------------------
                 1 |        5          33        27.5
                 2 |        5          22        27.5
      -------------+---------------------------------
          Combined |       10          55          55
      
      Unadjusted variance       22.92
      Adjustment for ties        0.00
                           ----------
      Adjusted variance         22.92
      
      H0: ex(count==1) = ex(count==2)
               z =  1.149
      Prob > |z| = 0.2506
      Exact prob = 0.3095
      
      P{ex(count==1) > ex(count==2)} = 0.720

      Comment


      • #4
        Leonardo Guizzetti what do you mean by by group ‘Missy’ please ?

        Comment


        • #5
          Rich Goldstein apologies can you explain why you use ‘long ex, i (id) j(count) when you renamed the variables ax ex1 and ex2 - thanks
          reshape long ex, i(id) j(count) (j = 1 2)

          Comment


          • #6
            it made it easy to use the command that I used to get the values in one variable (column) and the grouping variable in another - note from the ranksum help file that this is how the data need to be set up

            Comment


            • #7
              Originally posted by Martin Imelda Borg View Post
              Leonardo Guizzetti what do you mean by by group ‘Missy’ please ?
              Oops, that was my autocorrect, and was meant to be Fitbit. My apologies. Rich has demonstrated this for you.

              Comment

              Working...
              X