emtrends 中的自定义对比
发布时间:2022-07-24 07:55:04 264
相关标签: # 数据
有了这个示例数据集
dat <- data.frame(sample=c(1,2,3,4,5,6, 7,8,9,10,11,12,13,14), treatment=c(1,2,3,4,5,6, 1,2,3,4,5,6,7,8), condition=factor(c("A","A","A","A","A","A", "B","B","B","B","B","B","B","B")), scores=c(2,4,3,5,6,13, 41,30,30,23,24,24,10,8))
mod <- lm(scores~treatment*condition, data=dat)
我设置了自定义对比来查看 cross 的线性增加和cross变量condition A的treatment线性减少:condition Btreatment
con <- matrix(c(contr.poly(6)[,1],rep(0,8),rep(0,6),contr.poly(8)[,1]*-1), ncol=2)
con
[,1] [,2]
[1,] -0.5976143 0.00000000
[2,] -0.3585686 0.00000000
[3,] -0.1195229 0.00000000
[4,] 0.1195229 0.00000000
[5,] 0.3585686 0.00000000
[6,] 0.5976143 0.00000000
[7,] 0.0000000 0.54006172
[8,] 0.0000000 0.38575837
[9,] 0.0000000 0.23145502
[10,] 0.0000000 0.07715167
[11,] 0.0000000 -0.07715167
[12,] 0.0000000 -0.23145502
[13,] 0.0000000 -0.38575837
[14,] 0.0000000 -0.54006172
是否可以计算这些对比emmeans?
我知道我可以做到emm <- emtrends(mod, ~ condition, var="treatment"),这适合线性函数,但是如果我想使用我的自定义对比,可以将它们合并到 中emtrends吗?
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报