lme函数中的R错误:NA/NaN/Inf外部函数调用(arg 3)



我在nlme包中运行线性混合模型。

control <- lmeControl(maxIter=100,opt = c("optim"))
lme(response ~ 0+factorA+covariate,random=~1|factorB,
               weights=varIdent(form= ~1|factorA),control=control),

出现如下错误:

Error in logLik.reStruct(object, conLin) :NA/NaN/Inf in foreign function call (arg 3)

是否与收敛误差相同?还是其他人?

谢谢

这不是一个完整的答案,但是在注释中格式会很糟糕。(问题解决后将删除或编辑)

到目前为止,我还不能复制。下面是一个可复制的例子:
set.seed(101)
d <- data.frame(covariate=runif(500),response=rnorm(500),
                factorA=factor(sample(1:5,size=500,replace=TRUE)),
                factorB=factor(sample(1:5,size=500,replace=TRUE)))
library("nlme")
control <- lmeControl(maxIter=100,opt = c("optim"))
m1 <- lme(response ~ 0+factorA+covariate,random=~1|factorB,
          weights=varIdent(form= ~1|factorA),control=control,
          data=d)

既然这样做了,就很难再继续下去了。

如果你能提供一个可复制的例子将是最好的。除此之外,您可以通过设置options(error=recover)debug(nlme:::logLik.reStruct)来调试/帮助调试。进入浏览器后,可以尝试以下命令:

ls()
str(object)
str(conLin)
dput(object)
dput(conLin)

并提供适当的结果

最新更新