Announcement

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

  • comparing median between two variables with no grouping variable

    I am trying to compare the medians of two different variables without a grouping variable.

    In my dataset, each row (or observation) represents a pair of associated respiratory samples (one collected at some time point before an illness, and one collected during an illness). I am trying to compare the medians of virus concentrations at these two time points (before illness vs during illness) in our whole study population. Would use ranksum except I do not have a (by) or grouping variable, as the groups I am trying to compare are represented by two variables.

    When I attempt to compare the means, the syntax I used successfully was: "ttest mpv_ct == MPVCT" however this does not work to compare medians if i substitute ranksum or median for ttest.

    Appreciate any advice. thanks.

  • #2
    So it seems that you need to reshape your data to make this possible. By the way, it's a little loose to regard ranksum as a test comparing medians, but you can get the full story on that from decent texts.

    Comment


    • #3
      If you already have two separate variables in each observation, one variable representing the pre-illness measure and the other the during-illness measure, and you want to do a non-parametric test of the equality of their distributions you can do -signrank pre_measure = during_measure-. This will give you the Wilcoxon signed-ranks test for paired data.

      It is not, strictly speaking, a test of medians--but neither is -ranksum-. In fact, -signrank- is the matched-pair analog of -ranksum- (just as the matched-pair t-test is the matched-pair analog of the Student 2-group t-test). Since you were planning to use -ranksum-, I imagine that -signrank- is really what you want (although, as Nick pointed out, neither is really a test of medians).

      If you don't have the two measurements in separate variables but as separate observations in a single variable, then, as Nick suggested, you need to -reshape- your data first.

      Comment

      Working...
      X