例えば、4品種の名前がa,b,c,dで、分げつ数が多い順にd,a,b,cだとします。
同様の大小関係となるように値を設定(mango > apple > peach > melon)し多重比較してみましたが,私の環境「macOS(M1) 13.6.1, R 4.3.2, multcomp 1.4.25」でも同様の結果です(下記の記述例参照)。
multcomp のマニュアル の cld の部分に目を通しましたが値の大小関係と連動してアルファベットを設定する機能は読み取れませんでした。現在その機能には対応していないのかもしれません。
なお,下記の記述例の最後に記載のように値の大小関係に合わせて x のレベルを設定し多重比較すれば値の大小関係とアルファベットを対応させることはできるようです
R
1library(multcomp, quietly=TRUE)
2
3set.seed(7)
4N <- 10
5tuk1 <- data.frame(
6 x = factor(rep(c("apple", "peach", "melon", "mango"), rep(N, 4))),
7 y = c(as.integer(rnorm(N, 25, 2.5)), as.integer(rnorm(N, 20, 2.5)),
8 as.integer(rnorm(N, 15, 2.5)), as.integer(rnorm(N, 30, 2.5))))
9
10tuk1$x <- factor(tuk1$x, levels = c("apple", "peach", "melon", "mango"))
11tuk2 <- aov(y ~ x, data = tuk1)
12SG_res2 <- glht(tuk2, linfct = mcp(x="Tukey"))
13summary(SG_res2)
14##
15## Simultaneous Tests for General Linear Hypotheses
16##
17## Multiple Comparisons of Means: Tukey Contrasts
18##
19##
20## Fit: aov(formula = y ~ x, data = tuk1)
21##
22## Linear Hypotheses:
23## Estimate Std. Error t value Pr(>|t|)
24## peach - apple == 0 -3.400 1.148 -2.962 0.0263 *
25## melon - apple == 0 -9.400 1.148 -8.189 <0.001 ***
26## mango - apple == 0 4.400 1.148 3.833 0.0026 **
27## melon - peach == 0 -6.000 1.148 -5.227 <0.001 ***
28## mango - peach == 0 7.800 1.148 6.795 <0.001 ***
29## mango - melon == 0 13.800 1.148 12.021 <0.001 ***
30## ---
31## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
32## (Adjusted p values reported -- single-step method)
33cld(SG_res2, decreasing=TRUE)
34## apple peach melon mango
35## "d" "c" "b" "a"
36
37tuk1$x <- factor(tuk1$x, levels = c("mango", "apple", "peach", "melon"))
38tuk2 <- aov(y ~ x, data = tuk1)
39SG_res2 <- glht(tuk2, linfct = mcp(x="Tukey"))
40cld(SG_res2, decreasing=TRUE)
41## mango apple peach melon
42## "d" "c" "b" "a"
2023/12/03 08:08