K related samples

↬ Analyse


The non-parametric k related samples test, or Friedman Test, measures the differences between multiple samples. This is the non-parametric equivalent of the ‘repeated measures ANOVA’ which analyses independent categorical variables and a dependent continuous variable, such as 3 different treatment courses, and measures them by dependent continuous data, such hospital stay length. It then ranks the continuous data ordinally on 3 or more occasions and compares them (e.g. treatment A treated resolved infection quickest, then C, then B). It calculates the mean rankings and measures variation between data. The p-value calculated describes the statistical significance of the results  likelihood of having the sample differences if the samples were from the same population. If the p-value is 0.05 then the samples analysed in this test have a 5% likelihood of being from the same population. In this case, there would be no significant differences between the 3 treatment courses in terms of hospital stay length.

Post hoc tests can be further carried out, such as the Eisinga c.s. Exact test, to identify which paired sample were significantly different from the others by evaluating their mean rankings.


Measures significant differences between ordinal variables across multiple categorical groups. As it is similar to the one-way ANOVA, it can be used as a substitute when the data doesn’t quite fit the one way repeated ANOVA requirements (eg non parametric).


Must be 3 or more occasions/measurements of data. 

Worked Example

Download the example Excel file ‘Friedmans’. The example here looks for differences in the 5 yr survival rates when treated by treatment course A, B and C.

  1. In the file there are several headed columns
    • Subject - Which person is receiving the treatment
    • Treatment - Which treatment course they are receiving
    • [Cells] - how many days that person took to recover using that treatment
    • Rank (1-3) - ranking of treatment efficacy by days of recovery (1 fewest days, 3 most days)
  2. Open rBiostatistics » Comparative » Non-parametric » K related samples » ↬ Analyse
  3. Browse and upload the Excel file
    • Note that you must choose file type (.xlsx or .csv) as appropriate
    • .csv files also need you to define your separator 
  4. Select the variable you would like to include in your analysis
  5. Define the variables for both row and column
  6. Various tabs are available to view the statistical output on the top
    • Error bar and Box plot are also available
  7. Analysis

    (Friedman Test)

    # A tibble: 1 x 6

      .y.       n statistic    df      p method       

    * <chr> <int>     <dbl> <dbl>  <dbl> <chr>        

    1 score     6       5.2     2 0.0743 Friedman test

    (Effect Size)

    # A tibble: 1 x 5

      .y.       n effsize method    magnitude

    * <chr> <int>   <dbl> <chr>     <ord>    

    1 score     6   0.289 Kendall W small   

    (Multiple Pairwise Comparison)

    # A tibble: 3 x 9

      .y.   group1   group2      n1    n2 statistic     p p.adj p.adj.signif

    * <chr> <chr>    <chr>    <int> <int>     <dbl> <dbl> <dbl> <chr>       

    1 score X Course Y Course     8     8       6.5 0.892 1     ns          

    2 score X Course Z Course     8     8       0   0.062 0.188 ns          

    3 score Y Course Z Course     8     8       1   0.125 0.375 ns 


  8. Results
    • Df: Degree of freedom = 2
    • Statistic (Friedman Test) = 5.2
    • Pr(>F) (p-value) = 0.074
  9. Interpretation
    • There is no statistically significant differences between the courses when treating this condition


By Ka Siu Fan & Ka Hay Fan





↬ Analyse