Announcement

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

  • Testing eqality of medians between two variables/separate collumns

    Hello, how should I go forth in testing eqality of medians between two variables/separate collumns? I am trying to compare the median ages between two variables that aren't grouped together. I unerstand that I should use the Wilcoxon signed-ranks test, but for me this only works when they are grouped into the same variable.

    Many thanks in advance.

  • #2
    for -signrank- or for -median-, the data need to be in one variable (column); depending on your data setup, about which you say nothing, you might want to use -reshape- or -stack- (or possibly something else) to achieve this; if you were to give a data example, using -dataex- and posting within CODE blocks (see the FAQ), more specific advice could be given

    added in edit - you could probably use the bootstrap on your data as is, but,, again, without a data example, one can't be sure and can't give good advice

    Comment


    • #3
      Further, that test is only a test of equality of medians with extra assumptions.

      Comment


      • #4
        I don't think Wilcoxon-Mann-Whitney is not really a test of medians. There's a few papers on that issue.

        ranksum is an option.

        qreg would work and is straightforward, but again the data would need to be stacked.

        Code:
        sysuse auto, clear
        tabstat mpg, by(foreign) stats(mean p50)
        reg mpg foreign
        qreg mpg foreign  //defaults to p50

        Comment


        • #5
          This might work. Just replace "mpg if foreign==0/1" with the variables of interest.

          Code:
          sysuse auto, clear
          program diffmed, rclass
                    quietly summarize mpg if foreign==0, detail
                    local med0 = r(p50)
                    quietly summarize mpg if foreign==1, detail
                    local med1 = r(p50)
                    return scalar difference = `med0'-`med1'
            end
          
          bootstrap r(difference), rep(1000): diffmed

          Comment

          Working...
          X