Error message in nlme example present in R but not in S

情到浓时终转凉″ 提交于 2019-12-10 21:24:23

问题


I am working through Mixed Effects Models in S and S-Plus in R but some of the code does not produce the results in-text. In Chapter 6 one of the examples fails to converge with the code supplied.

The example is a non-linear mixed effects model performed on the Phenobarb dataset supplied with the nlme package.

library(nlme)

fm1Pheno.nlme <- nlme(model = conc ~ phenoModel(Subject, time, dose, lCl, lV),
                      data = Phenobarb,
                      fixed = lCl + lV ~ 1,
                      random = pdDiag(lCl + lV ~ 1),
                      start = c(-5,0),
                      na.action = na.pass, 
                      naPattern = ~ !is.na(conc))

fm1Pheno.nlme

This first model runs fine, but the second model, based on the first

fm2Pheno.nlme <- update( fm1Pheno.nlme,
                         fixed = list(lCl ~ Wt, lV ~ Wt + ApgarInd),
                         start = c(-5.0935, 0, 0.34259, 0, 0),
                         control = list(pnlsTol = 1e-6) )

..returns the error

Error in nlme.formula(model = conc ~ phenoModel(Subject, time, dose, lCl,  : 
  maximum number of iterations (maxIter = 50) reached without convergence

This second model apparently work in S but not in R. Can anyone suggest a solution? Is the error due to some difference between S and R?


回答1:


We may deal with this by adjusting the pnlsTol parameter:

fm2Pheno.nlme <- update(fm1Pheno.nlme,
                        fixed = list(lCl ~ Wt, lV ~ Wt + ApgarInd),
                        start = c(-5.0935, 0, 0.34259, 0, 0),
                        control = list(pnlsTol = 0.019))

To see why it makes sense, try adding msVerbose = TRUE to control and see how the values keep jumping around if the tolerance parameter is low. Increasing pnlsTol is a pretty common way to deal with such convergence issues, see, e.g.,

  • Tricks for fitting data in nlme?

  • Gastric Emptying Analysis with R: Miscellaneous

  • Correlation structure of nested nonlinear mixed model

  • [R] nlme and pnlsTol

  • [R-sig-ME] nlme: "Singularity in backsolve" error in ODE-defined, but not in closed-form model



来源:https://stackoverflow.com/questions/52884290/error-message-in-nlme-example-present-in-r-but-not-in-s

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!