目前不存在此功能userfriendlyscience
。通过查看具有事后测试结果的数据框的行名,您可以看到哪些均值不同,以及哪些 p 值不同。我不确定哪个包包含sweetpotato
数据集,但使用ChickWeight
R 附带的数据集(并在oneway
手册页上使用):
oneway(y=ChickWeight$weight, x=ChickWeight$Diet, posthoc='games-howell');
产量:
### (First bit removed as it's not relevant.)
### Post hoc test: games-howell
diff ci.lo ci.hi t df p
2-1 19.97 0.36 39.58 2.64 201.38 .044
3-1 40.30 17.54 63.07 4.59 175.92 <.001
4-1 32.62 13.45 51.78 4.41 203.16 <.001
3-2 20.33 -6.20 46.87 1.98 229.94 .197
4-2 12.65 -10.91 36.20 1.39 235.88 .507
4-3 -7.69 -33.90 18.52 0.76 226.16 .873
前三行将组 2、3 和 4 与 1 进行比较:使用 alpha = .05,1 和 2 具有相同的均值,但 3 和 4 更高。这使您可以计算multCompLetters
in所需的逻辑向量multcompView
。基于手册页中的示例?multcompView
:
### Run oneway anova and store result in object 'res'
res <- oneway(y=ChickWeight$weight, x=ChickWeight$Diet, posthoc='games-howell');
### Extract dataframe with post hoc test results,
### and overwrite object 'res'
res <- res$intermediate$posthoc;
### Extract p-values and comparison 'names'
pValues <- res$p;
### Create logical vector, assuming alpha of .05
dif3 <- pValues > .05;
### Assign names (row names of post hoc test dataframe)
names(dif3) <- row.names(res);
### convert this vector to the letters to compare
### the group means (see `?multcompView` for the
### references for the algorithm):
multcompLetters(dif3);
这产生了最终结果:
2 3 4 1
"a" "b" "c" "abc"
这就是你需要的,对吧?
我将此功能添加到 中userfriendlyscience
,但这个新版本将在 CRAN 上发布还需要一段时间。同时,如果需要,您可以在https://github.com/Matherion/userfriendlyscience/blob/master/R/oneway.R获取此更新的源代码(按“原始”按钮以获得简单的-下载版本的源代码)。
请注意,如果您需要此更新版本,则需要将参数设置posthocLetters
为TRUE
,因为它是FALSE
默认的。例如:
oneway(y=ChickWeight$weight,
x=ChickWeight$Diet,
posthoc='games-howell',
posthocLetters=TRUE);