Reputation: 2738
I want to fit zero inflated negative binomial random effect models using glmmadmb() in R. These are reproducible as they use data from the package.
Attempt 1:
om1 <- glmmadmb(SiblingNegotiation~FoodTreatment*SexParent+offset(log(BroodSize)),
random=(1|Nest),
zeroInflation=TRUE,family="nbinom",data=Owls)
gives the error:
Error in process_randformula(formula, random, data = data) :
object 'Nest' not found
Attempt 2:
om2 <- glmmadmb(SiblingNegotiation~FoodTreatment*SexParent+offset(log(BroodSize)),
random="~1|Nest",
zeroInflation=TRUE,family="nbinom",data=Owls)
gives the error:
Error in `colnames<-`(`*tmp*`, value = character(0)) :
attempt to set 'colnames' on an object with less than two dimensions
How can I successfully do this function call with the random
argument?
Upvotes: 1
Views: 105
Reputation: 2738
So to fit this model with the random
argument, try removing the quotes from your Attempt 2 code:
om3 <- glmmadmb(SiblingNegotiation~FoodTreatment*SexParent+offset(log(BroodSize)),
random=~1|Nest,
zeroInflation=TRUE,family="nbinom",data=Owls)
or use as.formula and the quotes:
om4 <- glmmadmb(SiblingNegotiation~FoodTreatment*SexParent+offset(log(BroodSize)),
random=as.formula("~1|Nest"),
zeroInflation=TRUE,family="nbinom",data=Owls)
Which is equivalent to the example given on the help page for glmmadmb(), which does not use the random
argument:
om5 <- glmmadmb(SiblingNegotiation~FoodTreatment*SexParent+
(1|Nest)+offset(log(BroodSize)),
zeroInflation=TRUE,family="nbinom",data=Owls)
> identical(om3$fitted, om5$fitted)
[1] TRUE
> identical(om4$fitted, om5$fitted)
[1] TRUE
> identical(om3$fitted, om4$fitted)
[1] TRUE
Upvotes: 2