[R-sig-ME] Random effects in glmmADMB

Joshua Wiley jwiley.psych at gmail.com
Wed Jun 20 04:32:57 CEST 2012


Hi Kirsty,

I believe you are just missing parentheses.  What happens when you try:

amphs_zinb_bionull<-glmmadmb(VCAmphCountI~Zone + BPeriod +(1|Site),
data=Amphs, zeroInflation=TRUE, family="nbinom")

You may find these two pages I wrote helpful.  They do not deal with
zero inflated negative binomial models specifically, but they do show
various random effect poisson models among others in R in both
glmmadmb and glmer (from lme4):

## mixed effects poisson using packages lme4 and glmmADMB with
corresponding SAS and Stata code
## may be helpful for translating between packages
http://www.ats.ucla.edu/stat/r/pages/mepoisson.htm

## linear mixed models and generalized linear mixed models
## primarily used to simulate a data set so models are not the focus
http://www.ats.ucla.edu/stat/r/pages/mesimulation.htm

It is a bit anathema to say on this list, but you likely could also do
what you want using proc nlmixed.  I have written an example of how to
write out your own model and log likelihood function for a zero
inflated poisson model with random effects in proc nlmixed here:

http://www.ats.ucla.edu/stat/sas/faq/zip_nlmixed.htm

you could extent this to negative binomial without too much work.

Finally, it may be that once you have zero inflation and random
effects, you no longer have over dispersion and a poisson may be
sufficient (i.e., the negative binomial may be overkill once you have
everything else done).  Just a thought you might check out.

Cheers and good luck!

Josh

On Tue, Jun 19, 2012 at 6:29 PM, Kirsty E. B. Gurney
<kegurney at alaska.edu> wrote:
> Good afternoon;
>
> I've previously had success using SAS to create generalized linear mixed models for data with a negative binomial distribution (count data of aquatic invertebrates). However, I've also recently confirmed that this data set is zero-inflated. To deal with the zero-inflation in the negative binomial distribution and maintain nested random effects (both basin and year, nested within site), I have tried to switch my models to R and use the glmmADMB package for a revised set of analyses..
>
> I seem to be having some problems with random effects parts of my models and am hoping that someone on this list may have been through a similar experience and be able to help.
>
> First I imported the data and ran a simplified version of the model with only fixed effects:
>
> amphs_zinb_simple<-glmmadmb(VCAmphCountI~Zone+BPeriod, data=Amphs, zeroInflation=TRUE, family="nbinom")
>
> This model ran with no apparent errors and results seemed feasible. Feeling confident that I knew what was going on, I then added one simple random effect to the model;
>
> amphs_zinb_bionull<-glmmadmb(VCAmphCountI~Zone + BPeriod +1|Site, data=Amphs, zeroInflation=TRUE, family="nbinom")
>
> Hmmm. This did not seem to go so well (see error & warning messages below). I have been through the raw data and can not find the NAs that are referred to, nor can I figure out why I get the warning message about the random factor (Site). Any insights or suggestions would be appreciated.  I don't want to try and incorporate further random effects until I know what I am doing wrong...
>
> Error: dims [product 1979] do not match the length of object [0]
> In addition: Warning messages:
> 1: In Ops.factor(1 + 1, Site) : | not meaningful for factors
> 2: In glmmadmb(VCAmphCountI ~ 1 + 1 | Site, data = Amphs, zeroInflation = TRUE,  :
>  NAs removed in constructing fixed-effect model frame: you should probably remove them manually, e.g. with na.omit()
> 3: In cbind(0, II[, -ncol(II)]) :
>  number of rows of result is not a multiple of vector length (arg 1)
>
> Thanks in advance,
> kbg
>
> -~-~-~-
> Kirsty E. B. Gurney, Ph.D.
> Alaska Cooperative Fish and Wildlife Research Unit
> Institute of Arctic Biology
> 209 Irving 1 Building
> University of Alaska Fairbanks
> Fairbanks, AK 99775
> T: (907) 474 - 7738
> -~-~-~-
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/



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