问题
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