1

glmer用于估计y数据聚类时对 logit 尺度的影响。在以下模型中

fit1 = glmer(y ~ treat + x + ( 1 | cluster), family = binomial(link = "logit")) 

exp系数treat是二元0-1处理变量的优势比,x是协变量,cluster是我们对随机效应(截距)建模的聚类指标。中估计风险比率的标准方法glm是使用log链接代替,即family=binomial(link = "log")。但是在glmer我得到错误

Error in (function (fr, X, reTrms, family, nAGQ = 1L, verbose = 0L, maxit = 100L,  : 
  (maxstephalfit) PIRLS step-halvings failed to reduce deviance in pwrssUpdate

打电话后

fit1 = glmer(y ~ treat + x + ( 1 | cluster), family = binomial(link = "log")) 

网络搜索显示其他人与Gamma家人有类似的问题。

正如下面可重现的示例所示,这似乎是一个普遍问题。因此,我的问题是:如何使用混合效应模型估计风险比glmer

可重现的示例 下面的代码模拟了重现问题的数据。

n = 1000                            # sample size
m = 50                              # number of clusters
J = sample(1:m, n, replace = T)     # simulate cluster membership
x = rnorm(n)                        # simulate covariate
treat = rbinom(n, 1, 0.5)           # simulate random treatment
u  = rnorm(m)                       # simulate random intercepts
lt = x + treat + u[J]               # compute linear term of logistic mixed effect model
p  = 1/(1+exp(-lt))                 # use logit link to transform to probabilities
y  = rbinom(n,1,p)                  # draw binomial outcomes
d  = data.frame(y, x, treat)

# First fit logistic model with glmer
fit1  = glmer( y ~ treat + x + (1 | as.factor(J)), 
               family = binomial(link = "logit"), data  = d) 
summary(fit1)

# Now try to log link    
fit2  = glmer( y ~ treat + x + (1 | as.factor(J)), 
               family = binomial(link = "log"), data  = d) 
4

1 回答 1

1

由于您的模型产生的值 > 1,因此返回此错误:

  • PIRLS step-halvings failed to reduce deviance in pwrssUpdate ...
    • 当使用lme4链接函数拟合 GLMM 时,链接函数不会自动将响应限制在分布族的允许范围内(例如,具有对数链接的二项式模型,其中估计的概率可以大于 1,或逆 Gamma 模型,其中估计的mean 可以是负数),得到这个错误并不罕见。发生这种情况是因为lme4没有做任何事情来约束预测值,所以会NaN弹出值,这些值没有得到很好的处理。如果可能,切换到约束响应的链接函数(例如二项式的 logit 链接或 Gamma 的 log 链接)。

不幸的是,建议的解决方法是使用不同的链接功能。

以下论文调查了一些用于计算 [调整后] 相对风险的替代模型选择:

于 2021-03-20T10:02:54.510 回答