【问题标题】:Specific within group comparisons for lsmeanslsmeans 的特定组内比较
【发布时间】:2019-03-24 22:56:59
【问题描述】:

我想限制使用 R 中的包 'lsmeans' 计算的事后对比。

library(nlme) #for gls
model<-gls(time~ benchmark*gc*opt, method="REML",data=d)

lsmeans.d<-lsmeans(model, ~benchmark:gc:opt)
pairs(lsmeans.d)

这会输出基准 x gc x opt 的所有可能组合的比较。

我的问题是:如何在 lsmeans 函数中指定仅计算和输出每个唯一 benchmark:gc 组合内的比较?

我只想知道它们是否在基准 x gc 的每个组合中的“开启和关闭”处理之间存在显着差异。我已经添加了红线来显示这一点。

以下原始数据:

来自2 的示例

d=expand.grid(obs=0:10, benchmark=c('antlr', 'bloat', 'chart', 'eclipse', 'fop', 'hsqldb', 'jython', 'luindex', 'lusearch', 'pmd', 'xalan'), gc=c('CopyMS', 'GenCopy', 'GenImmix', 'GenMS', 'Immix'), opt=c('on', 'off'), heapSize=seq(from=1.5, to=4, by=0.5))
d$time = rexp(nrow(d), 0.01)+1000
d$time = d$time + abs(d$heapSize-3)*100
d$time[d$opt=='on'] = d$time[d$opt=='on']-200
 
d$time[d$opt=='on' & d$benchmark=='bloat'] = d$time[d$opt=='on' & d$benchmark=='bloat'] + 190
d$time[d$opt=='on' & d$benchmark=='pmd' & d$gc=='Immix'] = d$time[d$opt=='on' & d$benchmark=='pmd' & d$gc=='Immix'] + 600

ggplot() +
facet_grid(gc~benchmark) +
geom_boxplot(data=d, mapping=aes(x=opt, y=time, color=opt))

【问题讨论】:

    标签: r lsmeans


    【解决方案1】:

    感谢这里的灵感找到答案: first answer by rvs

    Using the FIRST version of your 'fit' model, do lsm = lsmeans(fit, ~A*B|C) and then contrast(lsm, list(c = c(1,0,0,-1)) – rvl Nov 24 '16 at 21:33
    

    答案:

    lsm = lsmeans(model, ~benchmark*opt|gc)
    pairs(lsm)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-21
      • 1970-01-01
      相关资源
      最近更新 更多