2

在阅读了 emmeans 的小插曲后,我仍在为可能有一个非常简单的解决方案而苦苦挣扎。

我模拟了 2 组 6 名受试者的一些数据。测量时间长达 360 分钟 (ExpDelta)。我的 lme 模型如下:

library(lme4)
library(emmeans)

lme.model = lmer(Value ~ Treatment*ExpDelta + Baseline + (1 | SubjectNr), data = df) 

现在,我可以计算每个时间点的 emmeans 对比度:

emm.s <- emmeans(lme.model, pairwise ~ Treatment |  ExpDelta)  # emmeans for every time point

或仅通过治疗:

emm.s <- emmeans(lme.model, 'Treatment') # emmeans over the whole investigation period
pairwise_emm<-pairs(emm.s)

两个结果看起来都符合预期。但现在我只想比较 2 个治疗组,而排除 ExpDelta 240 和 360 组,我不知道如何。

所以我的问题是:在排除 ExpDelta 240 和 360 的数据时,安慰剂与 1 mg 药物 Y 的 p 值是多少?

参考数据集如下:

df<-structure(list(SubjectNr = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 
5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 
7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 
10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 
12L, 12L, 12L, 12L), Treatment = structure(c(2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L), .Label = c("Placebo", "1 mg drug Y"), class = "factor"), 
    ExpDelta = c("30", "60", "90", "120", "240", "360", "30", 
    "60", "90", "120", "240", "360", "30", "60", "90", "120", 
    "240", "360", "30", "60", "90", "120", "240", "360", "30", 
    "60", "90", "120", "240", "360", "30", "60", "90", "120", 
    "240", "360", "30", "60", "90", "120", "240", "360", "30", 
    "60", "90", "120", "240", "360", "30", "60", "90", "120", 
    "240", "360", "30", "60", "90", "120", "240", "360", "30", 
    "60", "90", "120", "240", "360", "30", "60", "90", "120", 
    "240", "360"), Baseline = c(9.64, 9.64, 9.64, 9.64, 9.64, 
    9.64, 7.92, 7.92, 7.92, 7.92, 7.92, 7.92, 5.88, 5.88, 5.88, 
    5.88, 5.88, 5.88, 11.79, 11.79, 11.79, 11.79, 11.79, 11.79, 
    11.07, 11.07, 11.07, 11.07, 11.07, 11.07, 9.38, 9.38, 9.38, 
    9.38, 9.38, 9.38, 12.37, 12.37, 12.37, 12.37, 12.37, 12.37, 
    8.51, 8.51, 8.51, 8.51, 8.51, 8.51, 10.86, 10.86, 10.86, 
    10.86, 10.86, 10.86, 8.13, 8.13, 8.13, 8.13, 8.13, 8.13, 
    11.79, 11.79, 11.79, 11.79, 11.79, 11.79, 9.3, 9.3, 9.3, 
    9.3, 9.3, 9.3), Value = c(10.72, 11.58, 11.3, 11.28, 10.39, 
    10.09, 8.78, 10.71, 11.01, 9.98, 8.15, 7.85, 6.6, 8.65, 7.86, 
    7.7, 6.61, 6.88, 12.91, 13.3, 14.13, 14.57, 12.31, 11.02, 
    10.78, 12.93, 13.07, 12.07, 11.92, 11.8, 10.62, 10.62, 12.26, 
    11.7, 10.86, 8.97, 13.03, 12.86, 13.5, 11.45, 12.78, 12.7, 
    9.14, 9.08, 7.81, 8.56, 8.51, 7.73, 10.86, 11.25, 11.5, 11.21, 
    10.6, 11.59, 8.57, 7.54, 7.87, 8.07, 7.56, 8.7, 11.46, 11.33, 
    12.1, 12.18, 11.69, 11.53, 9.73, 10.01, 8.85, 9.91, 10.02, 
    9.01)), row.names = c(NA, -72L), class = "data.frame")
4

1 回答 1

2

我认为您的问题最有可能的解释将由

emm <- emmeans(lme.model, "Treatment", 
               at = list(ExpDelta = c("30", "60", "90", "120")))
pairs(emm)

有关参数? ref_grid的详细信息,请参阅at

于 2020-02-27T01:13:18.493 回答