Skip to content

Using as.formula with glmmADMB

1 message · Alison Fairbrass

#
Dear all,

I am using as.formula to create a number of models with the same main
effects and different interaction terms using the following code:

mainEffects <- "poly(LC1,2) + poly(LC2,2) + poly(LC3,2) + poly(LC4,2) +
poly(LC5,2) +"

interactionTerms <- c("poly(LC1,2):poly(LC2,2)", "poly(LC1,2):poly(LC3,2)",
"poly(LC1,2):poly(LC4,2)", "poly(LC1,2):poly(LC5,2)")

loop<-0

for (interactionTerm in interactionTerms){

  newformula <- as.formula(paste('SPR ~', mainEffects, interactionTerm,'+
(1|Site)'))

  loop<-loop+1

  assign(paste("M", loop, sep=""), glmer(newformula, family=poisson, data =
dat))

}

This works fine when fitting models using glmer. However, when assigning
the model using glmmADMB (e.g. assign(paste("M", loop, sep=""),
glmmadmb(newformula, zeroInflation=TRUE, family="nbinom", data=dat)) I
receive the following error message:

Error in f[2] : object of type 'symbol' is not subsettable

Does glmmADMB not work with as.formula?

I am using glmmADMB v.0.7 with R v.3.1.2.

Many thanks in advance for your assistance,