gpt4 book ai didi

r - 如何在 R 中运行 Dunnett C 事后检验?

转载 作者:行者123 更新时间:2023-12-04 04:41:14 24 4
gpt4 key购买 nike

我在 r 中用我的数据集(不等的样本量,不等的方差)运行了一个双向方差分析:在 3 个物种中测量了 1 个变量(每个物种中有雄性和雌性)。
这在物种之间产生了显着的结果,所以我想知道哪些成对比较产生了显着性。我知道包中有一些函数可以在 R 中执行事后测试:
例如

Dunnett 的事后检验来自 http://www.uwlax.edu/faculty/toribio/math305_fall09/multiple.txt .
所需的包:“multcomp”、“mvtnorm”、“survival”、“splines”

library(multcomp)           
test.dunnett=glht(anova_results,linfct=mcp(method="Dunnett"))
confint(test.dunnett)
plot(test.dunnett)

*注意:glht 在“multcomp”中描述

但 Dunett 的检验旨在将所有组与对照组进行比较。相反,我想将所有组相互比较,Dunnett C.
有谁知道执行 Dunnett C 的包或知道如何对其进行编码? (方程在: http://pic.dhe.ibm.com/infocenter/spssstat/v21r0m0/index.jsp?topic=%2Fcom.ibm.spss.statistics.help%2Falg_posthoc_unequalvar.htm )

最佳答案

(所以 method 项在别处定义,不像我假设的那样是参数的名称。)在 uwlax.edu 网站上链接的代码中有三个多重比较示例。第二个给出了您想要的内容,即一组所有对的比较。这不是“Dunnett 的 C”,但我的经验是,R 的作者通常会提供最强大的测试,并且使使用过时的测试变得不那么方便。 SPSS 网站中对 Dunnett 的 C 代码的引用已有 40 年的历史。 ghlt 的引用和 TukeyHSD 函数是最新的,作者受到高度尊重。我认为没有令人信服的理由使用 Dunnett 的 C,而是使用实现目标的 TukeyHSD 选项:

 method1=c(96,79,91,85,83,91,82,87)
method2=c(77,76,74,73,78,71,80)
method3=c(66,73,69,66,77,73,71,70,74)

score=c(method1,method2,method3)
method=c(rep(1,length(method1)),
rep(2,length(method2)),
rep(3,length(method3)))
method=factor(method)
anova_results=aov(score~method)
anova_results
#------------
Call:
aov(formula = score ~ method)

Terms:
method Residuals
Sum of Squares 1090.6190 387.2143
Deg. of Freedom 2 21

Residual standard error: 4.29404
Estimated effects may be unbalanced
#----------
summary(anova_results)
#------------------
Df Sum Sq Mean Sq F value Pr(>F)
method 2 1090.6 545.3 29.57 7.81e-07 ***
Residuals 21 387.2 18.4
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

TukeyHSD(anova_results)
#--------------
Tukey multiple comparisons of means
95% family-wise confidence level

Fit: aov(formula = score ~ method)

$method
diff lwr upr p adj
2-1 -11.178571 -16.78023 -5.5769151 0.0001590
3-1 -15.750000 -21.00924 -10.4907592 0.0000006
3-2 -4.571429 -10.02592 0.8830666 0.1113951

TukeyHSD(anova_results, ordered=T)
#---------------
Tukey multiple comparisons of means
95% family-wise confidence level
factor levels have been ordered

Fit: aov(formula = score ~ method)

$method
diff lwr upr p adj
2-3 4.571429 -0.8830666 10.02592 0.1113951
1-3 15.750000 10.4907592 21.00924 0.0000006
1-2 11.178571 5.5769151 16.78023 0.0001590

关于r - 如何在 R 中运行 Dunnett C 事后检验?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18855099/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com