【问题标题】:glmer mixed models inconsistent between lme4 updatesglmer 混合模型在 lme4 更新之间不一致
【发布时间】:2014-01-07 03:07:17
【问题描述】:

这是一篇很长的文章。我无法在 lme4 版本之间获得一致的模型结果。我的旧电脑运行的是 R 3.0.0 “Masked Marvel”,带有 0.999999-2 版本的 lme4,而我的新工作电脑运行的是 R 3.0.2 “Frisbee Sailing”,带有 lme4 版本 1.1-2。他们没有给我相同的模型输出。省略了新的 lme4,我在我的旧笔记本电脑上一个接一个地安装了每个包更新并运行模型。然后,更新 R 本身并运行模型。最后,我对 R 3.0.2 的包进行了进一步更新,并再次运行模型。它们与原始分析保持一致。我无法使用最新的 R 3.0.0 中的 MASS 包和最新的 R 3.0.2 中的 nlme 包运行模型。我在这些情况下收到的错误消息是相同的,如下所示: “validObject(.Object) 中的错误:无效类“mer”对象:槽 L 必须是尺寸 dims['q'] 的单调 LL' 分解”

在我更新到 lme4 1.1-2 以完成我的分析之前,我想知道是否有人可以帮助阐明这一点。 R Studio 中链接的地址似乎没有更新日志……http://cran.rstudio.com/web/packages/lme4/NEWS

也许我的其他事情发生了变化?我一直在使用相同的数据文件,并在 R 中进行相同的设置。

我不知道如何附加数据,或者如何让这一切更容易让你们自己完成。我可以通过一些指导来做到这一点。以下是更新前 2 个模型和更新后相同模型的输出。这种变化也发生在我在这里没有包含的模型中,有些模型比其他模型更糟糕。它肯定会影响 AIC 排名。

lme4 版本 0.999999-2 R 版本 3.0.0 (2013-04-03) -- “蒙面奇迹”

at1500o <- glmer(apred ~ 
                 (1 | fFarm) + (1 | Eps) + (1 | fExp),
                 family = binomial,
                 data = PU3.atristis)                
summary(at1500o)

Number of levels of a grouping factor for the random effects
is *equal* to n, the number of observations
Warning message: In mer_finalize(ans) : false convergence (8)

Generalized linear mixed model fit by the Laplace approximation 
Formula: apred ~ (1 | fFarm) + (1 | Eps) + (1 | fExp) 
   Data: PU3.atristis 
   AIC      BIC     logLik      deviance
   182.2    193     -87.11      174.2
Random effects:
 Groups      Name           Variance    Std.Dev.  
 Eps        (Intercept)     1.6630e+01  4.0780e+00
 fFarm      (Intercept)     2.4393e+00  1.5618e+00
 fExp       (Intercept)     5.8587e-13  7.6542e-07
Number of obs: 110, groups: Eps, 110; fFarm, 17; fExp, 2

Fixed effects:
                Estimate  Std. Error  z value   Pr(>|z|)    
(Intercept)     -6.1406     0.7126    -8.618   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

假收敛didn’t seem to be a problem

at1500a <- glmer(apred ~ 
                      pctfield1500 * factor(SiteTrt) +
                      (1 | fFarm) + (1 | Eps) + (1 | fExp),
                    family = binomial,
                    data = PU3.atristis)                
summary(at1500a)

Number of levels of a grouping factor for the random effects
is *equal* to n, the number of observations
Warning message: In mer_finalize(ans) : false convergence (8)

Generalized linear mixed model fit by the Laplace approximation 
Formula: apred ~ pctfield1500 + factor(SiteTrt) + pctfield1500:factor(SiteTrt) + (1 | fFarm) + (1 | Eps) + (1 | fExp) 
   Data: PU3.atristis 

   AIC      BIC     logLik      deviance
   185.2    209.5   -83.59      167.2

Random effects:
 Groups     Name            Variance    Std.Dev.  
 Eps        (Intercept)     2.4539e+01  4.95370375
 fFarm      (Intercept)     8.1397e-01  0.90220336
  fExp      (Intercept)     1.3452e-08  0.00011598
Number of obs: 110, groups: Eps, 110; fFarm, 17; fExp, 2

Fixed effects:
                               Estimate  Std. Error  z value  Pr(>|z|)   
(Intercept)                    -6.82245    2.64044    -2.584   0.00977 **
pctfield1500                   -0.01041    0.10849    -0.096   0.92353   
factor(SiteTrt)2               2.47654     3.97069     0.624   0.53282   
factor(SiteTrt)3               4.33391     4.65551     0.931   0.35190   
pctfield1500:factor(SiteTrt)2  -0.05073    0.13117    -0.387   0.69895   
pctfield1500:factor(SiteTrt)3  -0.05729    0.14524    -0.394   0.69323   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
                (Intr)  pc1500    f(ST)2   f(ST)3  p1500:(ST)2
pctfild1500         -0.876                                 
fctr(StTr)2     -0.665  0.582                          
fctr(StTr)3     -0.571  0.504     0.380                   
p1500:(ST)2     0.724   -0.827   -0.850   -0.417            
p1500:(ST)3     0.654   -0.747   -0.435   -0.887    0.618

Lme4 版本 1.1-2 R版本3.0.2(2013-09-25)——“飞盘航行”

at1500o <- glmer(apred ~ 
                 (1 | fFarm) + (1 | Eps) + (1 | fExp),
                 family = binomial,
                 data = PU3.atristis)                
summary(at1500o)

Generalized linear mixed model fit by maximum likelihood ['glmerMod']
 Family: binomial ( logit )
Formula: apred ~ (1 | fFarm) + (1 | Eps) + (1 | fExp) 
   Data: PU3.atristis 

      AIC           BIC         logLik      deviance 
      236.8296      247.6316    -114.4148   228.8296 

Random effects:
 Groups      Name           Variance    Std.Dev. 
 Eps        (Intercept)     4.799e+01   6.927e+00
 fFarm      (Intercept)     6.542e-01   8.088e-01
 fExp       (Intercept)     6.056e-10   2.461e-05
Number of obs: 110, groups: Eps, 110; fFarm, 17; fExp, 2

Fixed effects:
             Estimate     Std. Error     z value   Pr(>|z|)    
(Intercept)   -7.975        1.115        -7.154   8.43e-13 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

不再有警告,但一切都大不相同了。模型拟合语句已从拉普拉斯近似变为最大似然 ['glmerMod']。

at1500a <- glmer(apred ~ 
                      pctfield1500 * factor(SiteTrt) +
                      (1 | fFarm) + (1 | Eps) + (1 | fExp),
                    family = binomial,
                    data = PU3.atristis)                
summary(at1500a)

Generalized linear mixed model fit by maximum likelihood ['glmerMod']
 Family: binomial ( logit )
Formula: apred ~ pctfield1500 + factor(SiteTrt) + pctfield1500:factor(SiteTrt) + (1 | fFarm) + (1 | Eps) + (1 | fExp) 
   Data: PU3.atristis 

      AIC           BIC         logLik      deviance 
      242.7874      267.0917    -112.3937   224.7874 

Random effects:
 Groups     Name            Variance    Std.Dev. 
 Eps        (Intercept)     3.346e+01   5.784e+00
 fFarm      (Intercept)     1.809e-07   4.253e-04
 fExp       (Intercept)     4.380e-11   6.618e-06
Number of obs: 110, groups: Eps, 110; fFarm, 17; fExp, 2

Fixed effects:
                              Estimate  Std. Error  z value   Pr(>|z|)  
(Intercept)                   -7.46800      3.04197     -2.455    0.0141 *
pctfield1500                   0.00032      0.12301     0.003     0.9979  
factor(SiteTrt)2               2.05618      4.57444     0.450     0.6531  
factor(SiteTrt)3               6.72139      5.20895     1.290     0.1969  
pctfield1500:factor(SiteTrt)2 -0.04882      0.14911     -0.327    0.7434  
pctfield1500:factor(SiteTrt)3 -0.11324      0.16495     -0.686    0.4924  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
            (Intr)  pc1500    f(ST)2   f(ST)3  p1500:(ST)2
pctfild1500 -0.875                                 
fctr(StTr)2 -0.665  0.582                          
fctr(StTr)3 -0.584  0.511     0.388                   
p1500:(ST)2 0.722   -0.825   -0.850   -0.422            
p1500:(ST)3 0.653   -0.746   -0.434   -0.886    0.615 

干杯, 纳瓦

【问题讨论】:

  • 几个要点:(1)NEWS 可在cran.r-project.org/web/packages/lme4/news.html 或(开发版)github.com/lme4/lme4/blob/master/inst/NEWS.Rd 获得;在github.com/lme4/lme4/blob/master/misc/notes/release_notes.md 发布重大更新的发布说明。 (2) 您可以从 http://lme4.r-forge.r-project.org/repos 安装 lme4.0 软件包以实现向后兼容性... (3) 将您的数据发布到一些可公开访问的网站可能是最简单的。
  • PS 不一定相关,但您可能不应该尝试将只有两个级别的因子作为随机效应拟合——它不会很好地工作。
  • 谢谢,本。 glmer 不能很好地工作,或者模型不能很好地工作?两个都?我遇到的问题是我想包含两个实验的变化,但不想将模型中固定变量的数量推到我的样本量可以处理的范围之外。有什么建议吗?
  • 两者,但大多是后者。从两个观察中估计方差,这基本上就是你在这里所做的,通常会给出一个非常糟糕的估计。 MLE 通常会为零(即使真实值非零),也会有偏差。通过将实验视为随机效应而不是固定效应,您只需保存一个参数。请参阅glmm.wikidot.com/faq#fixed_vs_random 了解更多信息。
  • 好的,我有个主意。这是关于固定/随机哲学的有趣综合。再次感谢您一如既往的详细回复。

标签: r


【解决方案1】:

lme4 包的 1.0 版标志着一个重大变化,对基础拟合代码进行了相当大的修改。来自changelog:

由于内部计算机制发生了变化,结果来自 最新版本的 lme4 在数字上不会与那些相同 从以前的版本。对于定义合理的拟合,它们将 非常接近(在 1e-4 左右的数值公差范围内),但 对于不稳定或定义不明确的拟合,结果可能会发生变化,并且非常 不稳定的配合可能会失败,当他们(显然)成功之前 版本。同样,新版本的某些拟合可能会变慢, 虽然平均而言,新版本应该更快更稳定。 现在可以使用更多的数值调整选项(见下文); 非默认设置可能会恢复速度和/或能力以适应 没有错误的特定模型。如果您注意到显着或 使用新版本的 lme4 拟合模型时令人不安的变化, 请通知维护人员。

考虑到您的模型使用 0.9999 版本的 lme4 拟合会产生错误的收敛警告,您的模型可能属于本文所说的“不稳定拟合”类别。

【讨论】:

  • 他们可能是!感谢您为我找到了。
猜你喜欢
  • 2011-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-01
  • 2011-12-11
  • 2012-03-07
相关资源
最近更新 更多