Вы можете начать с теста anova, а затем использовать функцию TukeyHSD
, чтобы получить значения p для каждого сравнения:
AOV <- aov(Rate~Level, data = df)
Call:
aov(formula = Rate ~ Level, data = df)
Terms:
Level Residuals
Sum of Squares 0.0916076 0.5068768
Deg. of Freedom 3 16
Residual standard error: 0.1779882
Estimated effects may be unbalanced
TukeyHSD(AOV)
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = Rate ~ Level, data = df)
$Level
diff lwr upr p adj
B-A -0.066558621 -0.3783957 0.2452784 0.9272012
C-A -0.061063140 -0.4026635 0.2805372 0.9551663
D-A 0.126520253 -0.2624089 0.5154494 0.7890519
C-B 0.005495482 -0.2848090 0.2958000 0.9999404
D-B 0.193078874 -0.1516699 0.5378277 0.4049948
D-C 0.187583392 -0.1843040 0.5594708 0.4923479
Отвечает ли он на ваш вопрос?
Воспроизводимый пример
structure(list(Row = 1:20, Rate = c(0.10791173, 0.0688004, 0.08644537,
0.29591635, 0.05081301, 0.026252, 0.80321285, 0.07682852, 0.18118814,
0.07787555, 0.15065913, 0.33362247, 0.03652168, 0.27998133, 0.05407451,
0.07233796, 0.08389061, 0.05220569, 0.05603418, 0.15875536),
Dogs = c(0, 0, 0, 0, 0, 0, 0.02974862, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0), MHI_2018 = c(59338L, 57588L, 50412L,
29267L, 37365L, 45400L, 39917L, 42132L, 47547L, 39907L, 39201L,
46495L, 49055L, 42423L, 40203L, 39057L, 45796L, 34035L, 39491L,
60367L), Points = c(236.4064, 229.4343, 200.8446, 116.6016,
148.8645, 180.8765, 159.0319, 167.8566, 189.4303, 158.992,
156.1793, 185.239, 195.4382, 169.0159, 160.1713, 155.6056,
182.4542, 135.5976, 157.3347, 240.506), Level = c("C", "C",
"C", "A", "B", "D", "D", "D", "B", "B", "C", "B", "B", "A",
"A", "A", "B", "B", "B", "C"), AGE65_MORE = c(8653L, 44571L,
10548L, 1661L, 3995L, 20247L, 6562L, 5980L, 7411L, 2953L,
2751L, 2915L, 10914L, 2481L, 7790L, 2629L, 15446L, 6921L,
12322L, 12400L), P_Elderly = c(15.56267, 20.44335, 18.23651,
16.3839, 20.2998, 17.71748, 19.52105, 22.97173, 16.78482,
22.99665, 20.72316, 19.45019, 19.92988, 23.15446, 21.06202,
19.01765, 18.51106, 18.06578, 17.26133, 15.14282)), row.names = c(NA,
-20L), class = c("data.table", "data.frame"))