Craig Lyon <craig.lyon <at> rogers.com> writes: > > Hi, > > I am trying to run a generalized linear regression using a negative binomial > error distribution. However, I want to use an overdispersion parameter that > varies (dependent on the length of a stretch of road) so glm.nb will not do. > > >From what I've read I should be able to do this using GLM by specifying my > own quasi family and describing the variance function using varfun, validmu, > dev.resids and initiate. However I cannot find any detailed discussion of > this method. Any help would be appreciated. > > ps I've done this in SAS so I know it should be possible! >
I think you'd be better off with the bbmle package, e.g. something like library(bbmle) mle2(response~dnbinom(mu=exp(logmu),size=exp(logk)),data=mydata, parameters=list(logmu~fac1+fac2,logk=roadlength), start=list(logmu=1,logk=0)) Slightly less efficient than setting up your own quasi family but probably much faster in terms of analyst time ... ______________________________________________ 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.