[R] Defining the "random" term in function "negbin" of AOD package

Lesnoff, Matthieu (ILRI) M.LESNOFF at CGIAR.ORG
Thu Dec 13 06:52:16 CET 2007


Dear Caroline

> How could I adjust this to function with the "negbin" function?
> Specifically, what would I use for the required "random" term?

The random argument is used to specify either a global parameter "phi" (random = ~ 1) or specific parameters "phi" for the levels of a given group factor (random = ~ group) (see ?negbin for what represents "phi" in negbin: Var[y] = μ + phi * μ^2)

In your example, it shoud be: negbin(formula = ..., random = ~ 1, data = ...)

Note that if your model has too many parameters, negbin may fail to reach the MLE.

You also can try the package 'gamlss' on CRAN. For your example, you can use the function gamlss as follows:

fm <- gamlss(formula = ..., family = NBI, sigma.formula = ~ 1, data = ...)
summary(fm)

Regards

ML


--------------------------------------------------
Matthieu Lesnoff
International Livestock Research Institute (ILRI)
PO BOX 30709, Nairobi, 00100 GPO, Kenya
Tel:   Off: (+254) 20 422 3000 (ext. 4801)
       Res: (+254) 20 422 3134
       Mob: (+254) 725 785 570
       Sec: (+254) 20 422 3013 
Fax: (+254) 20 422 3001
Email: m.lesnoff at cgiar.org 
--------------------------------------------------          

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Caroline Paulsen
> Sent: 13 December 2007 00:25
> To: r-help at r-project.org
> Subject: [R] Defining the "random" term in function "negbin" 
> of AOD package
> 
> I have tried glm.nb in the MASS package, but many models (I 
> have 250 models with different combinations of predictors for 
> fish counts data) either fail to converge or even diverge.
> 
>  
> 
> I'm attempting to use the negbin function in the AOD package, 
> but am unsure what to use for the "random" term, which is 
> supposed to provide a right hand formula for the 
> overdispersion parameter. I'm not even sure what this 
> statement means. Any advice you have would be greatly appreciated.
> 
>  
> 
> negbin(formula, random, data, phi.ini = NULL, warnings = FALSE, 
>          na.action = na.omit, fixpar = list(),
>          hessian = TRUE, control = list(maxit = 2000), ...)
> 
>  
> 
> My largest model using glm.nb looks like this:
> 
>  
> 
> negBin.glm1 <- glm.nb(Count ~ offset(log(Tow.Area)) + Basin + 
> Bathy + Hypoxia + Period + Depth + Basin*Depth + Bathy*Depth 
> + Hypoxia*Depth +
> 
>               Period*Depth + Basin*Period + Bathy*Period + 
> Hypoxia*Period + Hypoxia:Period:Depth + Bathy:Period:Depth +
> 
>               Basin:Period:Depth, 
> control=glm.control(maxit=1000), method="glm.fit",
> 
>                 data=Combined.Counts.df)
> 
>  
> 
> 
>  
> 
>  
> 
>  
> 
> Caroline E. Paulsen
> 
> Masters Candidate
> 
> School of Aquatic and Fishery Sciences
> 
> University of Washington
> 
> phone: 206.852.9539
> 
> email: cpaulsen at u.washington.edu
> 
>  
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
> 



More information about the R-help mailing list