[R] transmission of parameters to the glmmadmb function

Eric Elguero Eric.Elguero at ird.fr
Thu Jan 9 15:47:43 CET 2014


Hi everybody,

I wrote a function where several variables
are created, and the used in a generalized
mixed model, from the glmmADMB package.

here is part of the function:

<deleted lines where ni, spx and spy are created>
print(length(spy))

uu<-summary(glmmadmb(spy~sex+poswing+spx+(1|host),data=ni,
             family="nbinom",zeroInflation=True))

when I run the function I get

[1] 596
Error in eval(expr, envir, enclos) : object 'spy' not found

(so spy is known to the function "print" but not
to the function glmmadmb)


now I modify my function:

<deleted lines where ni, spx and spy are created>
print(length(spy))

ni$spy<-spy
ni$spx<-spx

uu<-summary(glmmadmb(spy~sex+poswing+spx+(1|host),data=ni,
             family="nbinom",zeroInflation=True))

and that works.

however, when I call glmmadmb interactively, it
accepts in the formula variables which are in
the dataframe specified by the 'data' argument,
as well as variables which are not.

and if in my function I replace glmmadmb by glm
it works even if spy and spx are not in the 'ni'
dataframe.

that puzzles me.



More information about the R-help mailing list