2013-05-10 97 views
-1

我在nlme包中运行线性混合模型。lme函数中的R错误:NA/NaN/Inf在外部函数调用中(arg 3)

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) 

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

感谢

+2

对不起,但没有足够的信息来回答这个问题。如果可能,请发布可复制的示例(http://tinyurl.com/reproducible-000),并且至少提供更多关于上下文的信息。 – 2013-05-10 18:49:12

+0

我编辑我原来的问题。谢谢 – Colin 2013-05-10 18:52:53

回答

0

这还不是很一个答案,但格式将是一个可怕的意见。 (如果问题得到解决,稍后将删除或编辑。)

到目前为止,我无法重现。这里有一个可重复的例子:

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) 

由于这个工程,它很难走得更远。

如果您可以provide a reproducible example,这将是最好的。除此之外,您可以通过设置options(error=recover)debug(nlme:::logLik.reStruct)来调试/帮助调试。一旦你进入浏览器,你可以尝试命令,如

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

并提供适当的结果。