[R-sig-ME] error message using glmmadmb

Ben Bolker bbolker at gmail.com
Wed Mar 7 16:14:35 CET 2012


  After looking at these data a bit I think (this may sound funny coming
from me) that all the fancy mixed-model stuff is overkill in this
situation.  The key is that you have a *nested* design -- your predictor
variables nsn and ara only vary across your 8 sites, not within them.
That means that in a classical analysis of variance you would get the
same answer if you just aggregated the data by site and ran a
fixed-effect model on the site averages, which is what I would recommend
here.  Aggregating the data in this way also takes care of a lot of the
distributional complexity; even if your individual samples have a funny
distribution, their averages (you have at least 8 samples per insect
type per site, and on average about 30) will be approximately normal
unless something really weird is happening.

Murtaugh, Paul A. 2007. “Simplicity and Complexity in Ecological Data
Analysis.” Ecology 88 (1): 56–62.
http://www.esajournals.org/doi/abs/10.1890/0012-9658%282007%2988%5B56%3ASACIED%5D2.0.CO%3B2.

  It's a secondary question (in my mind) to try to figure out why
glmmADMB isn't converging ...

  PS -- since your proportions sometimes approach 1, the
Poisson/negative binomial + offset approach won't work very well -- it
only works when counts are a small fraction of the total possible.

==========
data1 <- read.table("beepollenq.txt",header=TRUE)

## calculate proportions
data1 <- transform(data1,x=round(x),prop=x/Total.grains)
library(ggplot2)
library(mgcv)

g1 <- ggplot(data1,aes(x=ara,y=prop,colour=Insect.type))+
  geom_point(aes(size=Total.grains),alpha=0.8)+theme_bw()

## all together
g1 + geom_smooth(method="gam",family="binomial",aes(weight=Total.grains))

## separately:  one value of 'ara' per site
g1 +  facet_wrap(~Site)

## the same, but putting nsn on the x axis
g2 <- ggplot(data1,aes(x=nsn,y=prop,colour=Insect.type))+
  geom_point(aes(size=Total.grains),alpha=0.8)+theme_bw()
g2 + geom_smooth(method="gam",family="binomial",aes(weight=Total.grains))
g2 +  facet_wrap(~Site) ## one value of 'nsn' per site

## create aggregated version of data -- mean proportion
library(reshape)
m1 <- melt(subset(data1,select=c(Site,Insect.type,prop,nsn,ara)),
     id.var=c("Site","Insect.type"))
m2 <- cast(m1,Site+Insect.type~...,fun.agg=mean)
m2 <- m2[order(m2$Insect.type),]

ggplot(m2,aes(x=nsn,y=ara,size=prop))+
  geom_point(alpha=0.5)+facet_grid(.~Insect.type)+
  theme_bw()

ggplot(m2,aes(x=nsn,colour=ara,y=prop))+
  geom_point(alpha=0.5)+facet_wrap(~Insect.type,scale="free")+
  theme_bw()+geom_smooth(method="lm")

ggplot(m2,aes(x=ara,colour=nsn,y=prop))+
  geom_point(alpha=0.5)+facet_wrap(~Insect.type,scale="free")+
  theme_bw()+geom_smooth(method="lm")

On 12-03-07 09:23 AM, RH Gibson, School Biological Sciences wrote:
> Hi Ben,
> 
> I have attached the data.
> variable x is the number of strawberry grains out of Total.grains.
> The code is:
> 
> logTotal.grains<-log(Total.grains)
> 
> m7<-glmmadmb(x~nsn*Insect.type+ara*Insect.type+offset(logTotal.grains)+(1|Site),data=data1,
> zeroInflation=TRUE, family="nbinom")
> 
> summary(m7)
> 
> 
> Thanks,
> 
> Rachel.
> 
> 
> 
> 
> --On 05 March 2012 10:37 -0500 Ben Bolker <bbolker at gmail.com> wrote:
> 
>> On 12-03-05 10:24 AM, RH Gibson, School Biological Sciences wrote:
>>> summary(data1) file attached.
>>>
>>> Hope this can shed some light on the problem.
>>>
>>> Rachel.
>>>
>>
>>   Can you send the data themselves?
>>   The summary is good for sanity-checking but to go farther I would need
>> to look at the actual data.  (And, the format of the summary got mangled
>> in transmission ...)
>>
>>>
>>> --On 05 March 2012 09:22 -0500 Ben Bolker <bbolker at gmail.com> wrote:
>>>
>>> On 12-03-05 08:52 AM, RH Gibson, School Biological Sciences wrote:
>>>>>> That would make sense as I am able to fit a zero-inflated negative
>>>>>> binomial model, but not just the binomial. I have tried poisson
>>>>>> too, but this gave me the same error message as trying to fit the
>>>>>> binomial.
>>>>>>
>>>>>> The y variable is a count, offset by a sample total. There is
>>>>>> overdispersion and a lot of zeros in the data. Does using the
>>>>>> zero-inflated negative binomial make sense here?
>>>>>>
>>>>>> Thanks.
>>>
>>>   It very rarely makes sense to use the binomial and the negative
>>> binomial to fit the same set of data; the binomial has a fixed
>>> (typically known) upper limit, the Poisson and NB do not.  (The
>>> exception to this is that people will sometimes use Poisson/NB models
>>> when the upper limit is known but the observed frequency is very low
>>> -- this is especially common e.g. in epidemiology.)  ZINB, or plain
>>> old NB, probably make the most sense.
>>>
>>>   It's more interesting that you get an error message with the
>>> Poisson, which may indicate some glmmADMB instability.  What are the
>>> results of summary(data1)?  How many sites do you have?
>>>
>>>   Ben Bolker
>>>>>>
>>>>>>
>>>>>> --On 05 March 2012 08:25 -0500 Ben Bolker <bbolker at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> On 12-03-05 06:00 AM, RH Gibson, School Biological Sciences
>>>>>>> wrote:
>>>>>>>> Updated to latest version and now having new problems:
>>>>>>>>
>>>>>>>> m3<-
>>>>>>>> glmmadmb(x~nsn*Insect.type+ara*Insect.type+rap*Insect.type+fsize+of
>>>>>>>> fse t(
>>>>>>>>
>>>>>>>>
>>> logTotal.grains)+(1|Site),data=data1, zeroInflation=TRUE,
>>>>>>>> family="binomial") Error in glmmadmb(x ~ nsn * Insect.type +
>>>>>>>> ara * Insect.type + rap * Insect.type +  : The function
>>>>>>>> maximizer failed (couldn't find STD file) In addition: Warning
>>>>>>>> message: running command 'C:\WINDOWS\system32\cmd.exe /c
>>>>>>>> "C:/Program
>>>>>>>> Files/R/R-2.14.2/library/glmmADMB/bin/windows32/glmmadmb.exe"
>>>>>>>> -maxfn 500 -maxph 5 -noinit -shess' had status 1
>>>>>>>>
>>>>>>>
>>>>>>> This now means that the optimization failed for some reason.
>>>>>>> There are many reasons this can happen, mostly having to do with
>>>>>>> too-sparse or unusual data.  Without knowing anything about your
>>>>>>> data, the one thing that pops out is you are using a binomial
>>>>>>> family with zeroInflation=TRUE.  If your response is a matrix of
>>>>>>> successes and failures, that's unusual but plausible; if your
>>>>>>> response is a single 0/1 vector, then it doesn't make sense to
>>>>>>> use zero-inflation.  (If your response is anything else it's odd
>>>>>>> too, although that probably would have been caught earlier.) Try
>>>>>>> working through the troubleshooting steps under ?admbControl
>>>>>>> (and running with verbose=TRUE to see exactly what AD Model
>>>>>>> Builder reports as the problem).
>>>>>>>
>>>>>>> Ben Bolker
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Can you help with this?
>>>>>>>>
>>>>>>>> Many thanks, Rachel.
>>>>>>>>
>>>>>>>> --On 01 March 2012 18:10 +0000 Ben Bolker <bbolker at gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Ben Bolker <bbolker at ...> writes:
>>>>>>>>>
>>>>>>>>> [snip]
>>>>>>>>>
>>>>>>>>>> If you do this:
>>>>>>>>>>
>>>>>>>>>> mydata <-
>>>>>>>>>> data.frame(spdiv,nsn,ara,rap,Insect.type,fsize,Site)
>>>>>>>>>> glmmadmb(spdiv~(nsn+ara+rap)*Insect.type+fsize+(1|Site),family="n
>>>>>>>>>> bin om
>>>>>>>>>>
>>>>>>>>>>
>>> ")
>>>>>>>>>>
>>>>>>>>>> it ought to work.  However, it *should* work the way you
>>>>>>>>>> specified -- I will work on fixing the bug.
>>>>>>>>>>
>>>>>>>>>> thanks Ben Bolker
>>>>>>>>>
>>>>>>>>> This should be fixed now (i.e. in glmmADMB 0.7.2.7). It's
>>>>>>>>> still a good idea to use the data= argument.
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> R-sig-mixed-models at r-project.org mailing list
>>>>>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------- RH Gibson, School Biological Sciences
>>>>>>>> Rachel.Gibson at bristol.ac.uk
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------- RH Gibson, School Biological Sciences
>>>>>> Rachel.Gibson at bristol.ac.uk
>>>
>>>
>>>
>>>
>>> ----------------------
>>> RH Gibson, School Biological Sciences
>>> Rachel.Gibson at bristol.ac.uk
>>
> 
> 
> 
> ----------------------
> RH Gibson, School Biological Sciences
> Rachel.Gibson at bristol.ac.uk




More information about the R-sig-mixed-models mailing list