Tyler Rinker <tyler_rinker <at> hotmail.com> writes: > > > try: library(pscl) > > There's a zeroinfl for zero inflated neg. binom. > > Tyler
> > > > Dear All, > > I am trying to fit some data both as a negative binomial and a zero > > inflated binomial. > > For the first case, I have no particular problems, see the small snippet > > below > > set.seed(123) #to have reproducible results ## You don't actually need MASS::rnegbin, rnbinom in base ## R works fine (different parameter names) x6 <- c(rep(0,100),rnbinom(500,mu=5,size=4)) ## sample() is irrelevant, it just permutes the results library(pscl) zz <- zeroinfl(x6~1|1,dist="negbin") exp(coef(zz)[1]) ## mu zz$theta ## theta plogis(coef(zz)[2]) ## zprob Alternatively you can use fitdistr with the dzinbinom() function from the emdbook package: library(emdbook) fitdistr(x6,dzinbinom,start=list(mu=4,size=5,zprob=0.2)) The pscl solution is likely to be much more robust. ______________________________________________ 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.