我一直在研究如何使用计划中的对比,而不是事后的t测试。我通常使用ezANOVA ( III型变异数),但目前似乎没有考虑到使用ezANOVA进行有计划的对比。
另一方面,aov()是I型变量(我不想讨论哪种类型最适合哪种类型的设计)。使用aov() (用于组设计之间)来进行计划的对比是直接的,但是我想在重复的测量中进行一次III型的方差分析,坦率地说,ezANOVA有一个更方便用户的输出。
请记住,ezANOVA可以选择包含return_aov = TRUE,有人知道如何使用ezANOVA提供的信息来进行计划中的对比吗?
注意: return_aov = TRUE允许通过以下内容访问aov的输出:
summary.lm(ModelName$aov$'Participant:IndependentVariable1')上面的参与者是一个示例变量,添加到wid中的ezANOVA中
wid = .(Participant)summary.lm()通常用于在aov中显示计划对比的结果,这是ANOVA组与重复度量相反的结果。
我特别感兴趣的是,利用产出来进行计划中的对比,以进行反复测量的方差分析。
赏金目标
我想从这一慷慨中实现以下目标:
( 1)利用ezANOVA的输出量进行重复测量方差分析的计划对比。
( 1A)使用ezANOVA的输出来进行有计划的科目间的对比(这一次应该相对容易&因此不是要求赏金的必要条件)。
任何虚假的数据都应该足够了,但是这里有一个关于ezANOVA重复测量方差的格式的提醒:
ModelName <- ezANOVA(
data = DataSet,
dv = .(DependentVariable),
wid = .(Participant),
within = .(IndependentVariable1, IndependentVariable2),
type=3,
detailed = TRUE,
return_aov = TRUE)这是一个具有可复制数据和代码的相关问题,可以用来解决这个问题。
你可以找到一个这里给出了一些计划对比的背景。和他们做什么。
发布于 2019-01-02 17:11:09
emmeans包提供了适当的功能来计算aov和aovlist对象的自定义对比/估计边际均值(EMMs)的任意线性函数(有关支持模型的完整列表,请参见这里 )。
在下面的文章中,我使用了ANT数据集,它与ez包一起提供。
首先,我们使用ezANOVA建立了一个混合因子方差分析。请注意,为了获得有意义的Type-III测试,需要设置正交对比(例如,参见John的答案这里)。
library("ez")
library("emmeans")
# set orthogonal contrasts
options(contrasts = c("contr.sum", "contr.poly"))
data(ANT)
rt_anova <- ezANOVA(data = ANT[ANT$error == 0, ],
dv = rt,
wid = subnum,
within = .(cue, flank),
between = group,
type = 3,
return_aov = TRUE)然后,我们可以计算出所有组侧组合的EMMs值。
emm <- emmeans(rt_anova$aov, ~ group * flank)
emm
## group flank emmean SE df lower.CL upper.CL
## Control Neutral 381.5546 1.735392 53.97 378.0753 385.0339
## Treatment Neutral 379.9286 1.735392 53.97 376.4493 383.4079
## Control Congruent 381.6363 1.735392 53.97 378.1570 385.1155
## Treatment Congruent 379.7520 1.735392 53.97 376.2727 383.2313
## Control Incongruent 466.6770 1.735392 53.97 463.1977 470.1563
## Treatment Incongruent 452.2352 1.735392 53.97 448.7559 455.7145现在,在这些EMMs上计算所有成对比较或任何期望的对比是很容易的。
也请参阅这图书章节和我的答案这里,如果你需要更多关于如何从假设中获得对比权重的详细信息的话。
# all pairwise comparisons
pairs(emm, adjust = "Holm")
## contrast estimate SE df t.ratio p.value
## Control,Neutral - Treatment,Neutral 1.62594836 2.454215 53.97 0.663 1.0000
## Control,Neutral - Control,Congruent -0.08167403 2.473955 36.00 -0.033 1.0000
## Control,Neutral - Treatment,Congruent 1.80259257 2.454215 53.97 0.734 1.0000
## Control,Neutral - Control,Incongruent -85.12239797 2.473955 36.00 -34.407 <.0001
## Control,Neutral - Treatment,Incongruent -70.68062093 2.454215 53.97 -28.800 <.0001
## Treatment,Neutral - Control,Congruent -1.70762239 2.454215 53.97 -0.696 1.0000
## Treatment,Neutral - Treatment,Congruent 0.17664421 2.473955 36.00 0.071 1.0000
## Treatment,Neutral - Control,Incongruent -86.74834633 2.454215 53.97 -35.347 <.0001
## Treatment,Neutral - Treatment,Incongruent -72.30656929 2.473955 36.00 -29.227 <.0001
## Control,Congruent - Treatment,Congruent 1.88426660 2.454215 53.97 0.768 1.0000
## Control,Congruent - Control,Incongruent -85.04072394 2.473955 36.00 -34.374 <.0001
## Control,Congruent - Treatment,Incongruent -70.59894690 2.454215 53.97 -28.766 <.0001
## Treatment,Congruent - Control,Incongruent -86.92499054 2.454215 53.97 -35.419 <.0001
## Treatment,Congruent - Treatment,Incongruent -72.48321351 2.473955 36.00 -29.299 <.0001
## Control,Incongruent - Treatment,Incongruent 14.44177704 2.454215 53.97 5.884 <.0001
##
## Results are averaged over the levels of: cue
## P value adjustment: holm method for 15 tests
# custom contrasts
contrast(
emm,
list(c1 = c(1, -1, 0, 0, 0, 0), # reproduces first pairwise comparison
# emmean of row 1 - (emmean of row 1 + emmean of row 2) / 2; see EMMs table
# 381.5546 - (379.9286 + 381.6363) / 2
c2 = c(1, -0.5, -0.5, 0, 0, 0))
)
## contrast estimate SE df t.ratio p.value
## c1 1.6259484 2.454215 53.97 0.663 0.5105
## c2 0.7721372 2.136825 43.84 0.361 0.7196同样的情况也适用于纯粹的科目内的ANOVAs或科目之间的ANOVAs.
# within-subjects ANOVA
rt_anova_wi <- ezANOVA(data = ANT[ANT$error == 0, ],
dv = rt,
wid = subnum,
within = .(cue, flank),
type = 3,
return_aov = TRUE)
emm <- emmeans(rt_anova_wi$aov, ~ cue * flank)
contrast(
emm,
list(c1 = c(1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
c2 = c(1, -0.5, -0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0))
)
## contrast estimate SE df t.ratio p.value
## c1 47.31005 3.802857 170.34 12.441 <.0001
## c2 50.35320 3.293371 170.34 15.289 <.0001
# between-subjects ANOVA
rt_anova_bw <- ezANOVA(data = ANT[ANT$error == 0, ],
dv = rt,
wid = subnum,
within_full = .(cue, flank),
between = group,
type = 3,
return_aov = TRUE)
emm_bw <- emmeans(rt_anova_bw$aov, ~ group)
# custom linear function
contrast(
emm_bw,
list(c1 = c(2/3, 1/2))
)
## contrast estimate SE df t.ratio p.value
## c1 475.2899 0.8213448 18 578.673 <.0001https://stackoverflow.com/questions/35891062
复制相似问题