二项式回归“logit”与“cloglog”

机器算法验证 r 物流 贝叶斯 mlogit
2022-04-02 05:59:27

我正在使用二项式回归,分类因子有 9 个级别(名为“treat.group”),每组的样本量为 1-8。1 个治疗组具有所有阳性病例(即 1) - 这会在 R 中的“标准” glm() 函数中产生一个估计问题,该问题是由该治疗水平的“完美分离”引起的。所以,我正在使用 arm 包中的bayesglm。

我的问题是默认身份链接是“逻辑”,但我读过“cloglog”或(补充日志)在事件的概率非常小或非常大时经常使用。因此,由于我的模型在 1 个治疗组中表现出完美的分离,因此事件的概率非常大,我应该使用“cloglog”。使用 cloglog 为治疗组提供了显着的结果,完美分离,而“logit”则没有。

我是否有理由使用“cloglog”,或者有没有办法查看我的结果并确定哪个链接最好?

f1<- bayesglm(response~ treat.group,family=binomial(link="logit"), data=df)

f2 <- bayesglm(response~ treat.group,family=binomial(link="cloglog"), data=df)

(下面的数据框)

{ structure(list(response = c(0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L), treat.group = c("pctc", "phth", "phth", "phtl", "pltc", "pcth", "pltl", "phtc", "pctl", "phtc", "pcth", "pctl", "pctc", "phtl", "plth", "pltc", "phtc", "pcth", "phtl", "plth", "pctl", "pltc", "phtl", "pctc", "pcth", "pltc", "phtc", "phtl", "phtc", "pctl", "pctc", "pcth", "phth", "pctc", "phtl", "pcth", "phth", "phtc", "pcth", "phth")), .Names = c("response", "treat.group"), row.names = c(NA, -40L), class = c("tbl_df", "tbl", "data.frame"), na.action = structure(c(1L, 4L, 5L, 7L, 15L, 21L, 23L, 24L, 27L, 29L, 33L, 37L, 39L, 48L, 50L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 62L, 63L, 65L, 66L, 67L, 68L, 70L, 71L, 72L, 73L), .Names = c("1", "4", "5", "7", "15", "21", "23", "24", "27", "29", "33", "37", "39", "48", "50", "53", "54", "55", "56", "57", "58", "59", "60", "62", "63", "65", "66", "67", "68", "70", "71", "72", "73"), class = "omit")) }

1个回答

如果你拟合两个模型,一个是 logit,一个是 cloglog,你应该报告这两个模型的结果,并执行某种模型比较技术并报告结果。

至于模型,这是使用贝叶斯多级模型的绝佳情况(请参阅Gelman 的这篇论文 [PDF])。我们可以在组之间汇集信息,以告知样本量较小的组和看似极端结果的组(如在 phth 和 pltl 中)的估计。

用brms包拟合多级模型相当简单。这里的两个模型,一个带有 logit 链接,一个带有 cloglog 链接,将适合如下:

fit1 <- brm(
    response ~ (1 | treat.group),
    family = bernoulli,  # logit link is the default
    data = df,
    iter = 2e4,
    warmup = 2e3,
    control = list(adapt_delta = 0.999)
)

fit2 <- brm(
    response ~ (1 | treat.group),
    family = bernoulli(link = "cloglog"),
    data = df,
    iter = 2e4,
    warmup = 2e3,
    control = list(adapt_delta = 0.999)
)

这些将分别从模型中生成 72000 个样本,可以使用as.data.frame(fit). 对样本应用逆 logit 和逆 cloglog 后,我们得到以下对所需概率的估计:

group    prob using logit    sd       89% probability interval
--------------------------------------------------------------
pctc     0.405               0.169    0.12 to 0.66    
pcth     0.562               0.135    0.34 to 0.78    
pctl     0.438               0.170    0.15 to 0.7    
phtc     0.604               0.141    0.39 to 0.84    
phth     0.729               0.162    0.52 to 1    
phtl     0.529               0.142    0.3 to 0.76    
pltc     0.532               0.157    0.28 to 0.79    
plth     0.539               0.180    0.24 to 0.84    
pltl     0.623               0.193    0.39 to 1


group    prob using cloglog    sd       89% probability interval
----------------------------------------------------------------
pctc     0.395                 0.162    0.12 to 0.64    
pcth     0.545                 0.136    0.32 to 0.76    
pctl     0.422                 0.164    0.14 to 0.67    
phtc     0.589                 0.144    0.36 to 0.83    
phth     0.760                 0.182    0.52 to 1    
phtl     0.511                 0.142    0.28 to 0.74    
pltc     0.512                 0.158    0.25 to 0.77    
plth     0.517                 0.181    0.21 to 0.81    
pltl     0.627                 0.213    0.37 to 1

总体而言,使用 cloglog 链接的模型引起的概率收缩较小。值得注意的是,两个模型中 phth 的 89% 概率区间是相同的。

brms包支持使用PSIS -LOO进行模型比较。使用命令

loo(fit1, fit2, reloo = TRUE)

需要一段时间,但最终返回以下结果:

            LOOIC   SE
fit1        59.19 2.95
fit2        58.59 2.91
fit1 - fit2  0.60 0.46

这里估计 LOOIC 较低的模型具有更好的样本外预测精度。具有 cloglog 链接的模型的 LOOIC 略低,并且差异的标准误差 0.46 很小,因此我们可以得出结论,使用 cloglog 链接的模型略好于使用 logit 链接的模型。