Announcement

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

  • Post-hoc test after Friedman test

    Dear Stata community,

    is there a post-hoc test after a significant Friedman test that also accounts for repeated measurements? By the Friedman test, I am referring to the user written command -friedman-.

    In the literature I have read that the Dunn-Bonferroni test (in Stata implemented by user written command -dunntest-) is the appropriate post-hoc test for the Friedman test. However, I am unsure whether this test accounts for or lets the user account for repeated measurements the same way the Friedman test does. When studying the documentation on -dunntest-, I could not find any indication that this is the case.

    A brief elaboration on my research: I have 30 subjects that are measured four times, where each measurement point is several months apart. I want to test whether there is a significant change in the measurements on subject-level across time.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int ID double(m1 m2 m3 m4)
      4 53.850738525390625  55.07749652862549  39.79530906677246  95.73909759521484
      8 162.08384704589844  406.9361877441406  54.08695030212402 173.94705200195313
     24  238.5708465576172 135.21643829345703   64.7613353729248 232.27853393554688
     29  1376.376220703125  1391.450927734375 1693.4276123046875  881.0337829589844
     39   74.0460433959961 112.82498168945313  94.69554901123047 173.03167533874512
     43 138.18854522705078 170.98887634277344 153.36073303222656 25.744443893432617
     62  356.9570007324219 239.99945068359375  134.4717788696289 232.99710845947266
     63  82.06736183166504 203.57208251953125 239.47604370117188 183.60579681396484
     64 103.50431823730469 125.83489990234375 192.89240264892578  93.37303161621094
     65 168.73209381103516 178.03433227539063 221.94337463378906 203.73833465576172
     66   157.960307598114  463.9622802734375 343.06390380859375   79.6368932723999
     92  590.0118408203125 109.22186279296875 220.43071746826172 26.350412368774414
    103  422.5792541503906 350.69212341308594  331.5404968261719  76.05973052978516
    115  660.7237548828125  711.9779968261719 290.68446350097656 286.88926696777344
    116  356.1711120605469  330.7752685546875 168.86251831054688 162.41477966308594
    137  509.5492248535156 129.39233016967773 436.73602294921875  456.9159851074219
    139  71.01797485351563  82.09804916381836 178.60567474365234 138.33961486816406
    142  644.3618011474609 1074.0617980957031  759.8912353515625   73.2059326171875
    144  90.68435668945313 161.71163940429688 45.937503814697266  70.71932220458984
    176   964.295654296875 356.97882080078125 371.00975036621094 182.01382446289063
    199 258.25469970703125  672.3479919433594  898.4370727539063  152.0696258544922
    203  455.1990661621094 327.36590576171875 124.76653289794922  81.84178161621094
    204  641.9442138671875  423.8939971923828 1275.0164184570313 381.62115478515625
    205  28.08449363708496 474.22908782958984  648.0500793457031 1029.1197509765625
    207  82.31562042236328 142.22564315795898  64.92278289794922 167.06236267089844
    208 271.02222442626953  365.1441345214844  342.0950927734375 29.683542251586914
    211  609.6959533691406  289.8551025390625 177.98355102539063 241.85422134399414
    213 162.07401657104492 233.35426330566406 48.047428131103516 109.10914993286133
    217 186.35044860839844 369.10675048828125  947.0944213867188   93.8316764831543
    219 429.30731201171875 234.45760345458984 155.66828155517578 134.38890075683594
    220 139.77137756347656  427.6331787109375  32.00286865234375  514.7598266601563
    end

    My data does not follow a normal distribution and I want to account for the fact that the same subjects are measured repeatedly (i.e. that I have dependent groups). Hence, I conducted the Friedman test to test for differences between groups (i.e., the measurement times m1 to m4). The Friedman test was significant.

    Code:
    friedman m1 m2 m3 m4
    
    Friedman =  59.7702
    Kendall =    0.4981
    P-value =    0.0010
    I would now like to conduct an appropriate post-hoc test which also accounts for the fact that I have repeated measurements.

    Thank you very much.

    Best,
    Tobias
    Last edited by Tobias Engel; 16 Jun 2020, 13:57.

  • #2
    There's no interaction term, so why not just do a rank transformation and then fit a randomized blocks ANOVA? See below.

    .ÿ
    .ÿversionÿ16.1

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿquietlyÿinputÿintÿIDÿdouble(m1ÿm2ÿm3ÿm4)

    .ÿ
    .ÿrenameÿ*,ÿlower

    .ÿquietlyÿreshapeÿlongÿm,ÿi(id)ÿj(tim)

    .ÿegenÿdoubleÿrnkÿ=ÿrank(m)ÿ//ÿ<-ÿHere

    .ÿisidÿrnk

    .ÿ
    .ÿanovaÿrnkÿtimÿid

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿÿ124ÿÿÿÿR-squaredÿÿÿÿÿ=ÿÿ0.5290
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿ=ÿÿÿÿ28.8363ÿÿÿÿAdjÿR-squaredÿ=ÿÿ0.3562

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿPartialÿSSÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿMSÿÿÿÿÿÿÿÿFÿÿÿÿProb>F
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|ÿÿ84037.065ÿÿÿÿÿÿÿÿÿ33ÿÿÿ2546.5777ÿÿÿÿÿÿ3.06ÿÿ0.0000
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtimÿ|ÿÿ8469.0645ÿÿÿÿÿÿÿÿÿÿ3ÿÿÿ2823.0215ÿÿÿÿÿÿ3.39ÿÿ0.0213
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿidÿ|ÿÿÿÿÿÿ75568ÿÿÿÿÿÿÿÿÿ30ÿÿÿ2518.9333ÿÿÿÿÿÿ3.03ÿÿ0.0000
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿ74837.935ÿÿÿÿÿÿÿÿÿ90ÿÿÿ831.53262ÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿÿÿÿ158875ÿÿÿÿÿÿÿÿ123ÿÿÿ1291.6667ÿÿ

    .ÿ
    .ÿ//ÿLet'sÿtakeÿaÿlookÿ.ÿ.ÿ.
    .ÿlocalÿoptionsÿmsize(small)ÿmcolor(black)ÿylabel(ÿ,ÿangle(horizontal)ÿnogrid)

    .ÿ
    .ÿrvfplotÿ,ÿ`options'ÿyline(0,ÿlcolor(black)ÿlpattern(dash))

    .ÿquietlyÿgraphÿexportÿRankResidual-versus-Fitted.png

    .ÿ
    .ÿpredictÿdoubleÿres,ÿresiduals

    .ÿ
    .ÿ*ÿTails
    .ÿqnormÿresÿ,ÿ`options'

    .ÿquietlyÿgraphÿexportÿRankQ-Q.png

    .ÿ
    .ÿ*ÿCenter
    .ÿpnormÿresÿ,ÿ`options'

    .ÿquietlyÿgraphÿexportÿRankP-P.png

    .ÿ//ÿNotÿtooÿshabby
    .ÿ
    .ÿmarginsÿtim,ÿpwcompare(pveffects)ÿmcompare(bonferroni)

    PairwiseÿcomparisonsÿofÿpredictiveÿmarginsÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ124

    Expressionÿÿÿ:ÿLinearÿprediction,ÿpredict()

    ---------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿNumberÿof
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿComparisons
    -------------+-------------
    ÿÿÿÿÿÿÿÿÿtimÿ|ÿÿÿÿÿÿÿÿÿÿÿÿ6
    ---------------------------

    -----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-methodÿÿÿÿBonferroni
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿContrastÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|
    -------------+---------------------------------------
    ÿÿÿÿÿÿÿÿÿtimÿ|
    ÿÿÿÿÿ2ÿvsÿ1ÿÿ|ÿÿÿ5.967742ÿÿÿ7.324429ÿÿÿÿÿ0.81ÿÿÿ1.000
    ÿÿÿÿÿ3ÿvsÿ1ÿÿ|ÿÿ-4.709677ÿÿÿ7.324429ÿÿÿÿ-0.64ÿÿÿ1.000
    ÿÿÿÿÿ4ÿvsÿ1ÿÿ|ÿÿ-16.54839ÿÿÿ7.324429ÿÿÿÿ-2.26ÿÿÿ0.158
    ÿÿÿÿÿ3ÿvsÿ2ÿÿ|ÿÿ-10.67742ÿÿÿ7.324429ÿÿÿÿ-1.46ÿÿÿ0.890
    ÿÿÿÿÿ4ÿvsÿ2ÿÿ|ÿÿ-22.51613ÿÿÿ7.324429ÿÿÿÿ-3.07ÿÿÿ0.017
    ÿÿÿÿÿ4ÿvsÿ3ÿÿ|ÿÿ-11.83871ÿÿÿ7.324429ÿÿÿÿ-1.62ÿÿÿ0.657
    -----------------------------------------------------

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .


    anova has a set of postestimation commands at your disposal in addition to the ones shown here.


    Click image for larger version

Name:	RankResidual-versus-Fitted.png
Views:	1
Size:	28.7 KB
ID:	1559227


    Click image for larger version

Name:	RankQ-Q.png
Views:	1
Size:	25.6 KB
ID:	1559228


    Click image for larger version

Name:	RankP-P.png
Views:	1
Size:	31.8 KB
ID:	1559229

    Comment


    • #3
      Thank you, Joseph. Your feedback is greatly appreciated. I will look deeper into this approach.

      Comment

      Working...
      X