R error in lme function: NA/NaN/Inf in foreign function call (arg 3)

ぐ巨炮叔叔 提交于 2019-12-22 01:42:15

问题


I'm running linear mixed model in nlme package.

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

And, it come an error as following.

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

Is it the same as the convergence error? or others?

Thanks


回答1:


This isn't quite an answer, but the formatting would be horrible in a comment. (Will delete or edit later if the question gets resolved.)

I can't reproduce, so far. Here is a reproducible example:

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)

Since this works, it's hard to go farther.

It would be best if you can provide a reproducible example. Short of that, you can debug/help debug by setting options(error=recover) or debug(nlme:::logLik.reStruct). Once you get into the browser, you can try commands like

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

and provide the results as appropriate.



来源:https://stackoverflow.com/questions/16488736/r-error-in-lme-function-na-nan-inf-in-foreign-function-call-arg-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!