Model failure for nonlinear mixed-effects model fr

2019-07-17 05:50发布

问题:

I have been working through Mixed-Effects Models in S and S-Plus by Pinhiero and Bates and am discovering a lot of problems making the models in the book work.

The latest is this, using a constant plus power function to model heteroscedastic within-group error in the Theo dataset, (p.393). The error comes at the end of a model-building exercise. The first three models work in R but the last does not

library(nlme)
fm1Theo.nlme <- nlme( model = conc ~ SSfol(Dose, Time, lKe, lKa, lCl), 
                      data = Theoph,
                      fixed = lKe + lKa + lCl ~ 1,
                      random = lKe + lKa + lCl ~ 1)
fm2Theo.nlme <- update(fm1Theo.nlme, random = pdDiag(list(lKe ~ 1, lKa ~ 1, lCl ~ 1)))
fm3Theo.nlme <- update(fm2Theo.nlme, random = pdDiag(list(lKa ~ 1, lCl ~ 1)))
fm4Theo.nlme <- update(fm3Theo.nlme, weights = varConstPower(power=0.1))

...yielding the error message

Error in eigen(val, only.values = TRUE) : 
  infinite or missing values in 'x'
In addition: Warning messages:
1: In nlminb(c(coef(nlmeSt)), function(nlmePars) -logLik(nlmeSt, nlmePars),  :
  NA/NaN function evaluation
2: In nlminb(c(coef(nlmeSt)), function(nlmePars) -logLik(nlmeSt, nlmePars),  :
  NA/NaN function evaluation
3: In nlminb(c(coef(nlmeSt)), function(nlmePars) -logLik(nlmeSt, nlmePars),  :
  NA/NaN function evaluation
4: In nlminb(c(coef(nlmeSt)), function(nlmePars) -logLik(nlmeSt, nlmePars),  :
  NA/NaN function evaluation

Can anyone shed some light on this message, and how I might make it work?

回答1:

It looks like something that is supposed to be positive became negative during the optimization: functions such as sqrt and log when applied to negative numbers return NaN. Without digging deeper I tried to look into the variance model, which is supposed to return positive values. Setting higher initial value for const solves the issue:

fm4Theo.nlme <- update(fm3Theo.nlme, weights = varConstPower(const = 0.5, power = 0.1))


标签: r nlme