You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用emmeans获取clm模型不同cut下temp的单独累积概率?

解决方法

问题出在at参数仅用于限定分析的cut水平范围,但不会将其作为分组维度输出结果,导致结果默认对所有指定的cuts进行平均。要分别展示每个cut对应的temp累积概率,需将cut纳入emmeans的公式中。

正确代码示例

library(emmeans)
# 按cut分组,计算不同temp下的累积概率及组间对比
emm_results <- emmeans(fm, pairwise ~ temp | cut, mode = "cum.prob", at = list(cut = c("1|2", "3|4")))
# 查看结果
emm_results

结果说明

执行后会分别输出每个cut分组下,不同temp对应的累积概率及其置信区间,同时给出每个cut内temp的组间对比结果,不会再对cuts做平均处理。输出结构大致如下:

$emmeans
cut = 1|2:
     temp cumprob     SE  df asymp.LCL asymp.UCL
     cold   0.xxx  0.xxx Inf     0.xxx     0.xxx
     warm   0.xxx  0.xxx Inf     0.xxx     0.xxx

cut = 3|4:
     temp cumprob     SE  df asymp.LCL asymp.UCL
     cold   0.xxx  0.xxx Inf     0.xxx     0.xxx
     warm   0.xxx  0.xxx Inf     0.xxx     0.xxx

Confidence level used: 0.95 

$contrasts
cut = 1|2:
     contrast    estimate     SE  df z.ratio p.value
     cold - warm   0.xxx  0.xxx Inf   x.xxx    0.xxx

cut = 3|4:
     contrast    estimate     SE  df z.ratio p.value
     cold - warm   0.xxx  0.xxx Inf   x.xxx    0.xxx

如果偏好交叉表格形式展示结果,也可以将公式改为~ cut * temp,效果一致只是排版不同:

emmeans(fm, pairwise ~ cut * temp, mode = "cum.prob", at = list(cut = c("1|2", "3|4")))

内容的提问来源于stack exchange,提问作者locus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 11:00:04