用先前估计的值重新开始混合效应模型估计

And*_*rie 68 r lme4 mixed-models lmer

我正在使用lmer()lme4来估计混合效果模型.这很有效,但现在我想在固定数量的迭代中运行估算过程,然后通过指定由上一个估算过程计算的起始值来恢复过程.

根据这方面的帮助,?lmer可以通过设置参数:

  • start- 这些是新的起始值,根据帮助,可以ST从拟合模型中提取槽中的值并使用这些值,即使用x@ST
  • maxiter - 作为命名参数提供给 control

因此,例如,假设我想要lme使用iris数据,可以尝试这样做:

library(lme4)

# Fit model with limited number of iterations

frm <- "Sepal.Length ~ Sepal.Width | Species"

x <- lmer(frm, data=iris, 
          verbose=TRUE, control=list(maxIter=1), model=FALSE)

# Capture starting values for next set of iterations
start <- list(ST=x@ST)

# Update model
twoStep <-  lmer(frm, data=iris, 
          verbose=TRUE, control=list(maxIter=100), model=TRUE, 
          start=start)
Run Code Online (Sandbox Code Playgroud)

这有效.看一下输出,其中第一列是REML,即随机效应最大似然.特别注意模型2中的REML从模型1终止的地方开始:

> x <- lmer(frm, data=iris, 
+           verbose=TRUE, control=list(maxIter=1), model=FALSE)
  0:     264.60572: 0.230940 0.0747853  0.00000
  1:     204.22878: 0.518239  1.01025 0.205835
  1:     204.22878: 0.518239  1.01025 0.205835

> # Capture starting values for next set of iterations
> start <- list(ST=x@ST)

> # Update model
> twoStep <-  lmer(frm, data=iris, 
+           verbose=TRUE, control=list(maxIter=100), model=TRUE, 
+           start=start)
  0:     204.22878: 0.518239  1.01025 0.205835
  1:     201.51667: 0.610272  2.00277 0.286049
  2:     201.46706: 0.849203  1.94906 0.358809
  3:     201.44614: 0.932371  1.88581 0.482423
  4:     201.39421:  1.00909  1.71078 0.871824
  5:     201.36543:  1.00643  1.60453  1.01663
  6:     201.31066:  1.00208  1.35520  1.27524
  7:     201.28458:  1.08227  1.22335  1.35147
  8:     201.24330:  1.50333 0.679759  1.31698
  9:     201.11881:  1.95760 0.329767 0.936047
Run Code Online (Sandbox Code Playgroud)

但是,当我有一个不同的值时,maxIters它不再起作用:

x <- lmer(frm, data=iris, 
          verbose=TRUE, control=list(maxIter=3), model=FALSE)
start <- list(ST=x@ST)
twoStep <-  lmer(frm, data=iris, 
                 verbose=TRUE, control=list(maxIter=100), model=TRUE, 
                 start=start)
Run Code Online (Sandbox Code Playgroud)

请注意,REML值在264处重新开始,即开始:

> x <- lmer(frm, data=iris, 
+           verbose=TRUE, control=list(maxIter=3), model=FALSE)
  0:     264.60572: 0.230940 0.0747853  0.00000
  1:     204.22878: 0.518238  1.01025 0.205835
  2:     201.94075:  0.00000  1.51757 -1.18259
  3:     201.71473:  0.00000  1.69036 -1.89803
  3:     201.71473:  0.00000  1.69036 -1.89803

> # Capture starting values for next set of iterations
> start <- list(ST=x@ST)

> # Update model
> twoStep <-  lmer(frm, data=iris, 
+           verbose=TRUE, control=list(maxIter=100), model=TRUE, 
+           start=start)
  0:     264.60572: 0.230940 0.0747853  0.00000
  1:     204.22878: 0.518238  1.01025 0.205835
  2:     201.94075:  0.00000  1.51757 -1.18259
  3:     201.71473:  0.00000  1.69036 -1.89803
  4:     201.64641:  0.00000  1.82159 -2.44144
  5:     201.63698:  0.00000  1.88282 -2.69497
  6:     201.63649:  0.00000  1.89924 -2.76298
  7:     201.63649: 4.22291e-08  1.90086 -2.76969
  8:     201.63649: 4.22291e-08  1.90086 -2.76969
Run Code Online (Sandbox Code Playgroud)

问题:如何lmer()使用先前安装的模型获得的起始值可靠地重新启动?


会议信息:

packageVersion("lme4")
[1] ‘0.999999.2’
Run Code Online (Sandbox Code Playgroud)

The*_*ell 3

这是 lme4 中已确认的错误,根据评论

\n
\n

我已在 github.com/lme4/lme4/issues/55 \xe2\x80\x93 Andrie 记录了一个问题,2013 年 7 月 2 日 15:42

\n

现在应该针对 lmer 修复此问题(尽管不针对 glmer,这稍微棘手一些)。\xe2\x80\x93 本·博尔克 7 月 14 日

\n
\n

那是在版本 < 0.99999911-6 的时候;自 2013 年 9 月 21 日起, CRAN 上的 lme4版本已超过 1.0-4。

\n