问题
I am working through Pinhiero and Bates' book Mixed Effects Models in S and S-Plus in R. I am having trouble getting a model in Chapter 8 (p. 387) to converge.
library(nlme)
fm1Wafer.nlmeR <- nlme(current ~ A + B * cos(4.5679 * voltage) + C * sin(4.5679 * voltage),
data = Wafer,
fixed = list(A ~ voltage + I(voltage^2), B + C ~ 1),
random = list(Wafer = A ~ voltage + I(voltage^2),
Site = pdBlocked(list(A ~ 1, A ~ voltage + I(voltage^2)-1))),
start = c(-4.26, 5.62, 1.26, -0.10, 0.10), # starting values taken from fixed effects of another model earlier in the book
method = "REML",
control = nlmeControl(opt = "nlm"))
As you can see I have tried the nlm
optimizer. The default nlminb
optimiser does not work either. Both yield this error message
Error in nlme.formula(current ~ A + B * cos(4.5679 * voltage) + C * sin(4.5679 * :
maximum number of iterations (maxIter = 50) reached without convergence
In addition: Warning messages:
1: In logLik.reStruct(object, conLin) :
Singular precision matrix in level -2, block 1
2: In logLik.reStruct(object, conLin) :
Singular precision matrix in level -2, block 1
Any suggestions? There are several models based on this one downstream in the book so it would be nice to get it to converge.
回答1:
The error would suggest that setting something like nlmeControl(opt = "nlm", maxIter = 2000)
would help, but actually it didn't. I tried 4000 but it was taking forever...
What appears to be the real culprit is method = "REML"
. Leaving the default "ML"
gives the expected result.
fm1Wafer.nlmeR <- nlme(current ~ A + B * cos(4.5679 * voltage) + C * sin(4.5679 * voltage),
data = Wafer,
fixed = list(A ~ voltage + I(voltage^2), B + C ~ 1),
random = list(Wafer = A ~ voltage + I(voltage^2),
Site = pdBlocked(list(A ~ 1, A ~ voltage + I(voltage^2) - 1))),
start = c(-4.26, 5.62, 1.26, -0.10, 0.10))
来源:https://stackoverflow.com/questions/53926442/trouble-with-achieving-convergence-in-nonlinear-mixed-effects-model-in-pinhiero