# Change over time between two groups and within groups - Mann Whitney or Kruskal Wallis?

I have two groups (Control and Disease) and for each group a variable y is measured at three time points (0H, 24H, 48H). I want to know two things:

1. Does y change between Control and Disease at each timepoint i.e. Control 0H v Disease 0H etc
2. Does y change over time within each group ie Control 0H v Control 24H v Control 48H (all pairwise comparisons within a group)

For (1) I carried out a Wilcoxon to identify changes within each time point grouped by group (control and disease). However I am struggling with (2). So far I have grouped by each group and then run a Kruskal Wallis to see if any timepoints change in each group, I then follow this with a Dunns test to find out which timepoints are different. Is this the correct way to answer this question?

res.aov <- Data %>%
group_by(group)%>% # control and disease
kruskal_test(y ~ time) # change in the variable y. 'time' refers to
# the 6 groups - C0 C24 C48 D0 D24 D48


OR should I run a non parametric test for all pairwise comparisons (therefore addressing both (1) and (2)) but I am not interested in all the comparisons for example how Control at 0H differs from Disease at 24H... this will only make it harder to find significance.

n.b

• The data is not normally distributed and equal variances is not always met (based on Shapiro Wilk test, qq plots, and Levene test respectively)
• Control n = 15 (n=5 for each timepoint)
• Disease n = 30 (n=10 for each timepoint)

What I decided to go with in the end was Friedman due to the nature of the question being a non parametric one-way repeated measures test.

res.fried <- myd %>% groupby(group) %>%friedman_test(y ~ time | patient)

if (res.fried\$p < 0.05){
print(res.fried) # friedman is significant

# follow with a multiple comparisons wilcox post-hoc test
pwc <- myd %>%
wilcox_test(
y ~ time, paired = TRUE) %>%
}



I think you might be able to use Friedman's test for 3 or more repeated measures.

You can check out here that shows an example.

It would be even better to address the two questions in a single model. Then you would be looking into a non-parametric alternative for the two-way repeated measures ANOVA.

I found a good example interpretation of such a model here:

Imagine that a health researcher wants to help suffers of chronic back pain reduce their pain levels. The researcher wants to find out whether one of two different treatments is more effective at reducing pain levels. Therefore, 30 participants take part in the experiment. The two treatments, known as "conditions", are a "massage programme" (treatment A) and "acupuncture programme" (treatment B). Both programmes last 8 weeks. Therefore, the dependent variable is "back pain", whilst the two factors are the "conditions" (i.e., two groups: "treatment A", the massage programme, and "treatment B", the acupuncture programme) and "time" (i.e., back pain at three time points, which are our three groups: "at the beginning of the programme", "midway through the programme" and "at the end of the programme").
All 30 participants undergo treatment A and treatment B. However, the order in which they receive this differs, with the 30 employees being randomly split into two groups: (a) 15 participants first undergo treatment A and then treatment B, whilst (b) the other 15 participants start with treatment B and then undergo treatment A (i.e., this is known as counterbalancing and helps to reduce the bias that could result from the order in which a condition is provided).
At the end of the experiment, the researcher uses a two-way repeated measures ANOVA to determine whether any change in back pain (i.e., the dependent variable) is the result of the interaction between the "type of treatment" (i.e., the massage programme or acupuncture programme, which is one of our two factors) and "time" (i.e., our second factor). Irrespective of whether there is an interaction, follow-up tests can be performed to determine in more detail how the within-subjects factors affected back pain.

To apply a non-parametric alternative of this, I'd suggest applying the two-way repeated measures ANOVA to the ranked version of your y variable.

• Thank you. Is it correct to address the two questions in two separate ways? Sep 3, 2020 at 12:35
• @startswithH I've updated my answer to include this question Sep 3, 2020 at 14:48
• From my understanding, a two way repeated ANOVA requires n to be the same for both treatments/groups.. in my case the n is different between groups (10 v 15) so not sure if a two way test is the best way to go about it. I could be wrong! Sep 3, 2020 at 16:18