从R中的emmeans中移除一个对比



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

我模拟了两组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)

两个结果看起来都如预期。但现在我只想比较两个治疗组,而不包括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")

我认为最有可能回答您的问题

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

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

相关内容

  • 没有找到相关文章

最新更新