Возможно, это указывает на полезное направление.
library(tidyverse)
df = data.frame('pos'=c(1,2,3,1,2,3,1,2,3), # Using 3 as the last position
'sample'=c('A','A','A','B','B','B','C','C','C'),
'score'=c(1,10,5,20,40,10,0.1,5,4))
# Compute rank of each sample within each position
ranked = df %>% group_by(pos) %>%
mutate(rank=rank(score, ties.method='min')) %>%
ungroup()
# B seems to consistently score higher
ggplot(ranked, aes(pos, rank, color=sample)) +
geom_point(size=5)
# Kruskal-Wallis rank sum test of the null hypothesis that the rankings
# are from the same distribution for all samples.
kruskal.test(ranked$rank, ranked$sample)
#>
#> Kruskal-Wallis rank sum test
#>
#> data: ranked$rank and ranked$sample
#> Kruskal-Wallis chi-squared = 8, df = 2, p-value = 0.01832
# Pairwise Wilcoxon test for B vs C
df %>% filter(sample!='A') %>%
group_by(pos) %>%
mutate(rank=rank(score, ties.method='min')) %>%
ungroup() %>%
pivot_wider(id_cols='pos', names_from='sample', values_from='rank') %>%
{wilcox.test(.$B, .$C, paired=TRUE)}
#> Warning in wilcox.test.default(.$B, .$C, paired = TRUE): cannot compute exact p-
#> value with ties
#>
#> Wilcoxon signed rank test with continuity correction
#>
#> data: .$B and .$C
#> V = 6, p-value = 0.1489
#> alternative hypothesis: true location shift is not equal to 0
Если все оценки получены из одного и того же распределения, я думаю, вы могли бы сделать это те же тесты на счетах напрямую, без ранжирования.
Создано в 2020-01-10 с помощью пакета Представление (v0.3.0)