简体   繁体   English

R:事后比较,使用估算的边际均值,但不假设方差相等

[英]R: post-hoc comparisons using estimated marginal means but not assuming equal variances

I am trying to use R to run post-hoc comparisons following a significant interaction for a mixed-method Anova. 在尝试对混合方法Anova进行大量交互之后,我试图使用R进行事后比较。 I would like to do the post-hoc similar to SPSS [EMMEANS=TABLES(Group*time) COMPARE(Group) ADJ(BONFERRONI)], using estimated marginal means but not assuming equality of variance. 我想使用估计的边际均值但不假设方差相等,来进行类似于SPSS [EMMEANS = TABLES(Group * time)COMPARE(Group)ADJ(BONFERRONI)]的事后分析。

Dependent variable = 'depvar'. 因变量='depvar'。 I have 3 groups ('group') and 3 time points ('timept'), which are repeated measures over subjects ('id'); 我有3个组(“组”)和3个时间点(“ timept”),它们是对主题的重复测量(“ id”);

aov_car(depvar ~ group*timept + Error(id/(timept)), data=myData)

If I use pairwise.t.test I can compare groups separately for each time point, but the R uses observed means and I do not know how to force using the estimated marginal means of my model: 如果我使用pairwise.t.test,我可以在每个时间点分别比较组,但是R使用观察到的均值,并且我不知道如何使用模型的估计边际均值来强制:

for (itimept in unique(myData$timept)){
      idx=myData$timept==itimept
      pairwise.t.test(myData$depvar[idx],myData$group[idx],p.adj="bonferroni")
    }

If I use emmeans or lsmeans then R uses estimated marginal means, but assumes variances are the same (the SE in the results are all the same). 如果我使用emmeans或lsmeans,则R使用估计的边际均值,但假设方差相同(结果中的SE都相同)。

myfit=lme(depvar ~ group*timept, random = ~1|id/timept, data=myData)
emmeans(myfit, pairwise~group|timept, adjust="bonferroni")

How do I run post-hoc comparisons between groups for each time point, using estimated marginal means but not assuming equal variances, similar to SPSS? 如何使用估计的边际均值但不假设均方差来对每个时间点在组之间进行事后比较,类似于SPSS?

Thanks! 谢谢! Cristina 克里斯蒂娜

It isn't emmeans that assumes equal variances. 假定方差相等的不是emmeans It is the model that you fitted and subsequently handed to emmeans for further analysis. 这是您拟合的模型 ,随后将其传递给emmeans以作进一步分析。 Fit a different model using, I think, the weights argument, that specifies unequal variances. 我认为使用weights参数拟合不同的模型,该参数指定了不相等的方差。

I believe that this model will do the trick: 我相信这个模型会成功的:

myfit = lme(depvar ~ group*timept, 
            random = ~1|id/timept, 
            weights = varFunc(~ group*timept),
            data = myData)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM