[cc'ed back to r-help] I've started to take a look, and there's nothing immediately obvious about the problem with the fit (the warnings and errors are about a "non-positive-definite Hessian", which usually means an overfitted/poorly identified model) -- still working on whether there's a way to get more useful information.
As it turns out, glmmADMB's default behavior in this case is to just stop with an error. I could re-write things to allow it to tell you something (but it wouldn't be able to compute standard errors on the parameters). It's conceivable that you might get slightly different results (different enough that it would work in one case and fail in another) on different operating systems, different machines, etc. ... because the failure is really a case of something that's numerically on the edge, where negative values in a vector are illegal but the minimum might be -1e-7 in one case and 1e-7 in another -- i.e., different but just by numeric "fuzz". My first response to this sort of problem would be to see if you can simplify the model slightly -- e.g. are both random effects really necessary, etc.. Several things do suggest themselves from looking at the data: * your response variable ranges from 0 to 1, which doesn't make much sense for a negative binomial response distribution. What does your response variable represent? If it is overdispersed *binomial* data, then (1) you need to use something like a beta-binomial distribution instead (unfortunately not yet implemented in glmmADMB, but if you were desperate I might give it a whack) (2) you need to specify the denominators -- just the proportions won't do it. If you have just proportions, then you might be looking for a beta distributed response (although that has its own trickiness in dealing with response values of exactly 0 or 1). * your "Site" variable has only two levels. That makes dealing with it as a random variable extremely questionable (from a *philosophical* or experimental-design point of view it may be sensible to treat it as a random variable, but not practical: see http://glmm.wikidot.com/faq for discussion of this point). When I made it a fixed effect instead, I got (apparently) sensible results. * The plot of the data (see attached, I hope the attachment gets through) makes it clear that you have some potential balance problems. In section/segment combinations (C-D) x (3-5) you have only a few (often only one) observation in the (beetle.ev=1) case. Mild lack of balance is no problem in mixed models, but such severe lack of balance can be. (Note this doesn't guarantee a problem, but it is one of the factors that makes estimation less stable.) On 11-10-16 05:41 PM, James McCarthy wrote: > Hello Ben, > > Many thanks for offering to help with this. I have attached the data set > “stain.csv”. I have also attached a script file with all of the code > that should (hopefully) work for you. > > What I would like to get working is the function: > > nbin1<-glmmadmb(stainp~beetle.ev+Caged*Section/Segment+(1|Site)+(1|Log.code),data=dat1,family="nbinom") > > The issue is with the “beetle.ev” column (binary, presence/absence of > insects). Below is some code that works, all that has changed is that > “beetle.ev” is substituted with “Test”. This one works, and has some > data in pretty much the same format as “beetle.ev” (as you can see in > the .csv file). > > nbin2<-glmmadmb(stainp~Test+Caged*Section/Segment+(1|Site)+(1|Log.code),data=dat1,family="nbinom") > > For the life of me, I can’t figure out what’s wrong with this column. > > Thanks again for talking a look at it. > > Cheers, > James > > > James McCarthy > MSc (Ecology) candidate, University of Canterbury > c/o Scion (New Zealand Forest Research Institute) > Forestry Rd, P.O. Box 29-237, Christchurch, New Zealand > Ph: (03) 364 2987 Ext. 7820 > Cell: 027 268 5506 > Fax: (03) 364 2812 > Email: james.mccar...@scionresearch.com or > james.mccar...@pg.canterbury.ac.nz > www.scionresearch.com > > This email may be confidential and subject to legal privilege, it may > not reflect the views of the University of Canterbury, and it is not > guaranteed to be virus free. If you are not an intended recipient, > please notify the sender immediately and erase all copies of the message > and any attachments. > > Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more > information. >
## install.packages("glmmADMB",repos="http://glmmadmb.r-forge.r-project.org/repos",type="source") library(glmmADMB) dat1<-read.csv("stain.csv") ## attach(dat1) ## dangerous names(dat1) dat1<-transform(dat1, Site=factor(Site), ## BMB: fixed typo Log.code=factor(Log.code), Caged=factor(Caged), beetle.ev=factor(beetle.ev), Test=factor(Test)) ## BMB: this could also be done via colClasses= argument to read.csv nbin1<-glmmadmb(stainp~beetle.ev+Caged*Section/Segment+(1|Site)+(1|Log.code),data=dat1,family="nbinom", verbose=TRUE) nbin1B<-glmmadmb(stainp~beetle.ev+Caged*Section/Segment+Site+(1|Log.code),data=dat1,family="nbinom", verbose=TRUE) ## install.packages("coefplot2",repos="http://r-forge.r-project.org") coefplot2(nbin1B) library(ggplot2) ggplot(dat1,aes(x=beetle.ev:Caged,y=stainp,colour=Site))+ stat_sum(aes(size=..n..),alpha=0.5)+ facet_grid(Segment~Section)+opts(panel.margin=unit(0,"lines")) summary(nbin1) nbin2<-glmmadmb(stainp~Test+Caged*Section/Segment+(1|Site)+(1|Log.code),data=dat1,family="nbinom") summary(nbin2) library(coefplot2) coefplot2(nbin2) VarCorr(nbin2)
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.