[R] fitting generalized linear models using glmmPQL
Spencer Graves
spencer.graves at pdf.com
Sat Jan 28 18:39:29 CET 2006
I have not seen your particular error message often enough to be
confident I know what caused it:
>
> Error: NA/NaN/Inf in foreign function call (arg 1)
> In addition: Warning message:
> step size truncated due to divergence
In this case, the "Warning" seems more informative to me than the
actual "Error". The function "glmmPQL" is an iterative algorithm. The
"warining says that "step size truncated due to divergence. This kind
of warning might occur when the iteration found a long, gently sloping
plateau and tried to take a giant step to get beyond it. The algorithm
decided that the giant step was too large, and so tried to truncate it.
Since I don't have your data, I can only guess at what might have
caused it. My first guess is that you have the wrong model. Have you
considered the following:
modelo1a<-glmmPQL(DE ~ POB*TEMP*SALINITA, data = datos, random =
~ POB|CLON, family = poisson)
Putting nesting with the random effect in the 'fixed' model makes not
sense to me and generates an explosion of the number of "fixed effect"
parameters to be estimated. This might cause your problem all by itself.
If that doesn't solve the problem, have you tried to get a separate
fit for each level of "CLON" of the same fixed model, something like the
following:
(CLON.count <- table(datos$CLON))
n.CLON <- length(CLON.count)
glm.fits <- vector(n.CLON, mode="list")
for(i in 1:n.CLON)
glm.fits[[i]] <- try(glm(DE ~ POB*TEMP*SALINITA, data =
datos[datos$CLON==names(CLON.count[i])))
Under certain circumstances, "glmmPQL" could still return a good
answer even if "glm" returned an error for every level of CLON in this
loop. However, that's far from certain.
Also, have you tried changing the two "*" operators to "+" in the
fixed formula? This reduces the number of parameters to be estimated
and might give you sensible results.
If you are NOT using the latest version of R with the latest versions
of MASS and nlme, please upgrade before submitting another post. And
PLEASE do read the posting guide!
"www.R-project.org/posting-guide.html", especialy the bit about
providing a simple, self contained example. I sometimes solve problems
like this in the course of trying to prepare a simple example.
hope this helps.
spencer graves
Eduardo.Garcia at uv.es wrote:
> Hi, I have tried to run the following (I know it's a huge data set but
> I tried to perform it with a 1 GB RAM computer):
>
> library(foreign)
> library(MASS)
> library(nlme)
> datos<-read.spss(file="c:\\Documents and
> Settings\\Administrador\\Escritorio\\datosfin.sav",to.data.frame=TRUE)
> str(datos)
>
> `data.frame': 1414 obs. of 5 variables:
> $ POB : Factor w/ 6 levels "CHI","HOS","HYR",..: 1 1 1 1 1 1 1 1
> 1 1 ...
> $ CLON : num 1 1 1 1 1 1 1 1 2 2 ...
> $ TEMP : Factor w/ 2 levels "20 C","25 C": 1 1 1 1 2 2 2 2 1 1 ...
> $ SALINITA: Factor w/ 2 levels "15 g/l","30 g/l": 1 1 2 2 1 1 2 2 1
> 1 ...
> $ DE : num 17 0 7 1 15 28 4 14 13 16 ...
> - attr(*, "variable.labels")= Named chr "" "" "" "" ...
> ..- attr(*, "names")= chr "POB" "CLON" "TEMP" "SALINITA" ...
>
> datos$CLON<-as.factor(datos$CLON)
>
> modelo1<-glmmPQL(DE ~ (POB/CLON)*TEMP*SALINITA, data = datos, random =
> ~ 1|CLON, family = poisson)
>
> And I have obtained the following:
>
> Error: NA/NaN/Inf in foreign function call (arg 1)
> In addition: Warning message:
> step size truncated due to divergence
>
> This is the first time I've observed such a message and I have no idea
> about what does it mean. Is it possible that the process failed
> because of the size of the data set (180 levels of the CLON factor)?
> Or maybe is it a syntax problem?
>
> Thank you in advance.
>
>
> ********************************
> Eduardo Moisés García Roger
>
> Institut Cavanilles de Biodiversitat i Biologia
> Evolutiva - ICBIBE.
> Tel. +34963543664
> Fax +34963543670
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list