我用我的数据集(不相等的样本大小,不相等的方差)在r中运行了双向anova :1个变量在3个物种中测量(每个物种中有男性和女性)。这在物种之间产生了显着的结果,所以我想知道哪些成对比较产生了显着的意义。我知道在R中有用于执行后期测试的包中的函数:例如
来自http://www.uwlax.edu/faculty/toribio/math305_fall09/multiple.txt的邓内特的post测试。需要的包:"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)
发布于 2013-09-18 23:27:34
(因此,method项是在其他地方定义的,并不像我假设的那样是参数的名称。)在uwlax.edu网站上链接的代码中有三个多重比较的示例。第二个给出了您想要的结果,即所有配对的比较集。它不是"Dunnett's C“,但我的经验是,R的作者通常会给出最强大的测试,并使其不太方便使用过时的测试。SPSS网站上对邓尼特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.0001590https://stackoverflow.com/questions/18855099
复制相似问题