Error message in nlme example present in R but not

2019-07-05 02:51发布

问题:

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



标签: r nlme