hyu9910 发表于 2016-1-6 20:09 
不太理解你的问题。 一般地,c()是定义list或说向量的意思,而rbind()常用于将向量/list按行组成矩阵matrix
这是单因素协方差分析的一个例子,来自于multcomp包中的litter数据集,怀孕小鼠
被分为四个小组,每个小组接受不同剂量(0、5、50或500)的药物处理。产下幼崽的体重均值
为因变量,怀孕时间为协变量。利用multcomp包来检验用户自定义的均值假设。假定对未用药条件(第一组)与其他三种用药条件(后三组)影响是否不同感兴趣,代码是:
> library(multcomp)
>contrast<-rbind("no drug vs.drug"=c(3,-1,-1,-1))
>summary(glht(fit,linfct=mcp(dose=contrast)))
Simultaneous Tests for General Linear Hypotheses
Multiple Comparisons of Means: User-defined Contrasts
Fit: aov(formula = weight ~ gesttime + dose)
Linear Hypotheses:
Estimate Std. Error t value Pr(>|t|)
no drug vs. drug == 0 8.284 3.209 2.581 0.012 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)
我不懂的是为什么c(3,-1,-1,-1)表示第一组和后三组的比较,如果我想表示前两组和后两组的比较应该是什么呢?