Announcement

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

  • Comparison of medians

    Hi everybody and many thanks in advance.

    I have performed a very simple RCT with 5 participants on each group (placebo and experimental) and I have measured a biomarker at three points during follow-up
    Now I am interested in performing a median comparison between groups and also whithin groups testing for differences between baseline and the follow-up measures.
    What is the the best test to use to test for these whiting groups differences and also if the change at each point is different between groups?

    Thank you for your help.

    Germán

  • #2
    Here an example of the data:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float grupo int(total_score_0 total_score_1 total_score_12)
    0 124 103 125
    0 115 123 125
    0 121 104 115
    0   .   .   .
    0 109 117 113
    1 112  97  94
    1 114 112 109
    1 105  99 109
    1   .  99 116
    1 121   . 117
    end
    label values grupo grupo
    label def grupo 0 "control", modify
    label def grupo 1 "Tto", modify

    Thanks

    Germán

    Comment


    • #3
      Maybe something along the lines below. (You don't need to run the code shown; I've attached its log file to this post.)

      A couple of notes:

      First I renamed your variables to something shorter for convenience. (I've kept them denominated as "scores", although you've identified the outcome variable as a "biomarker".)

      Second, both types of median test (between and within) I believe are of low power. With n = 5, you might want to consider a parametric analysis. Toward that, I've shown one suggestion. Diagnostic plots (displayed below) don't raise any alarms so far as I can see albeit with a small sample, which I assume is from a pilot study. So for the full study, you might want to give serious consideration to the parametric data workup.

      Third, I assume that the numeric suffixes to your outcome variables represent time in months, and so I took an exploratory look at relaxing the residual covariance pattern. It's commented out below, but the sample size (power) is too low to make much of the results. Nevertheless, if what you show truly is one month and twelve months of follow-up, then you might want to consider an unstructured residuals covariance pattern for the full study. (On the other hand, it if's one minute and twelve minutes or even one hour and twelve hours in a clinical setting, then hassling with a more finicky convergence might not be worth the bother.)
      Code:
      version 17.0
      
      log using Biomarker.smcl, name(lo) nomsg
      
      clear *
      
      quietly input float grupo int(total_score_0 total_score_1 total_score_12)
      0 124 103 125
      0 115 123 125
      0 121 104 115
      0   .   .   .
      0 109 117 113
      1 112  97  94
      1 114 112 109
      1 105  99 109
      1   .  99 116
      1 121   . 117
      end
      
      *
      * Begin here
      *
      quietly compress
      
      rename grupo trt
      rename total_score_* sco#, renumber
      
      /* "I am interested in performing a median comparison between groups" */
      quietly egen double tot = rowmean(sco?)
      median tot, by(trt) exact
      
      /* "also whithin groups testing for differences between baseline and the follow-up measures" */
      signtest sco1 = sco2
      signtest sco1 = sco3
      
      /* "also if the change at each point is different between groups" */
      quietly generate int del12 = sco2 - sco1
      quietly generate int del13 = sco3 - sco1
      median del12, by(trt) exact
      median del13, by(trt) exact
      
      *
      * Also consider
      *
      generate byte pid = _n
      quietly reshape long sco, i(pid) j(tim)
      
      /*
      mixed sco i.trt##i.tim || pid: , noconstant residuals(unstructured, t(tim)) ///
          reml dfmethod(kroger) nolrtest nolog
      estimates store MANOVA
      mixed sco i.trt##i.tim || pid: , noconstant residuals(exchangeable) ///
          reml dfmethod(kroger) nolrtest nolog
      lrtest MANOVA
      */
      
      mixed sco i.trt##i.tim || pid: , reml dfmethod(kroger) nolrtest nolog
      quietly predict double res, residuals
      predict double xb, xb
      
      graph twoway ///
          scatter res xb if tim == 1, msymbol(O) msize(small) mcolor(black) || ///
          scatter res xb if tim == 2, msymbol(T) msize(medsmall) mcolor(black) || ///
          scatter res xb if tim == 3, msymbol(S) msize(small) mcolor(black) ///
          yline(0, lcolor(black) lpattern(dash)) ///
              ylabel( , angle(horizontal) nogrid) legend(off)
      quietly graph export RVF.png
      
      local opts mcolor(black) msize(small) rlopts(lcolor(gs8)) lpattern(dash) ///
          ylabel( , angle(horizontal))
      pnorm res, `opts'
      quietly graph export PP.png
      qnorm res, `opts'
      quietly graph export QQ.png
      
      quietly log close lo
      
      exit
      Click image for larger version

Name:	RVF.png
Views:	1
Size:	20.7 KB
ID:	1703555
      Click image for larger version

Name:	QQ.png
Views:	1
Size:	24.1 KB
ID:	1703557
      Click image for larger version

Name:	PP.png
Views:	1
Size:	27.6 KB
ID:	1703556
      Attached Files

      Comment


      • #4
        it if's → if it's

        Comment


        • #5
          Many thanks Joseph for your invaluable input.

          Comment

          Working...
          X