In our experiment, we have a data frame with the following columns:
Participant | Condition | parametricVariables | nonParametricVariables | orderNumber |
---|---|---|---|---|
1 | Condition 1 | 14.7 | 4 | 1 |
1 | Condition 2 | 11.4 | 1 | 2 |
2 | Condition 1 | 8.2 | 7 | 2 |
2 | Condition 2 | 13.0 | 6 | 1 |
... | ... | ... | ... | ... |
We have multiple parametric and multiple non-parametric variables and only two conditions. orderNumber
column represents the order in which the given participant tested the given condition - so the participant 1 first tested the Condition 1 and then Condition 2, while participant 2 tested them in the opposite order.
We are trying to see whether there is, despite our best efforts, an unsystematic variation based on the order of the conditions. So far we have just been using function calls and read the results from the output like this:
ParticipantOrder1 <- gameSummary %>% filter(orderNumber == 1)
Condition1Order1 <- ParticipantOrder1 %>% filter(Condition==condition1_label)
Condition2Order1 <- ParticipantOrder1 %>% filter(Condition==condition2_label)
ParticipantOrder2 <- gameSummary %>% filter(orderNumber == 2)
Condition1Order2 <- ParticipantOrder2 %>% filter(Condition==condition1_label)
Condition2Order2 <- ParticipantOrder2 %>% filter(Condition==condition2_label)
# Check parametric variables for normality
# ...
# Check for difference in the parametric variable across the two orders using Welch's t-test
t.test(ParticipantOrder1$parametric, ParticipantOrder2$parametric)
t.test(Condition1Order1$parametric, Condition1Order2$parametric)
t.test(Condition2Order1$parametric, Condition2Order2$parametric)
# Check for difference in the non-parametric variable across the two orders using Wilcoxon signed ranked test
wilcox.test(ParticipantOrder1$nonParametric, ParticipantOrder1$nonParametric, paired=TRUE,exact=FALSE)
wilcox.test(Condition1Order1$nonParametric, Condition1Order2$nonParametric, paired=TRUE,exact=FALSE)
wilcox.test(Condition2Order1$nonParametric, Condition2Order2$nonParametric, paired=TRUE,exact=FALSE)
As you can see, this approach gets rather unwieldy when one has multiple parametric and non-parametric variables. I am wondering whether there is a nicer way to collect all these test results into a table like this:
Variable | Condition | TestType | statistic | p-value |
---|---|---|---|---|
parametric1 | Both | Welch Two Sample t-test | 0.10317 | 0.9185 |
parametric1 | Condition 1 | Welch Two Sample t-test | 0.625 | 0.5462 |
parametric1 | Condition 2 | Welch Two Sample t-test | -0.69369 | 0.503 |
nonParametric1 | Both | Wilcoxon signed rank test with continuity correction | 18 | 0.6295 |
... | ... | ... | ... | ... |