我正在研究Pinhiero和Bates在R中的S和S-Plus中的混合效果模型。我很难使第8章(p。387)中的模型收敛。 / p>
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"))
如您所见,我已经尝试过nlm
优化器。默认的nlminb
优化器也不起作用。两者都会产生此错误消息
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
有什么建议吗?本书的下游有几种基于该模型的模型,因此最好使其收敛。
答案 0 :(得分:1)
该错误表明设置nlmeControl(opt = "nlm", maxIter = 2000)
之类的内容会有所帮助,但实际上没有帮助。我尝试了4000次,但时间长了...
真正的罪魁祸首是method = "REML"
。保留默认的"ML"
可获得预期的结果。
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))