[R] transmission of parameters to the glmmadmb function

David Winsemius dwinsemius at comcast.net
Thu Jan 9 21:49:44 CET 2014


On Jan 9, 2014, at 9:47 AM, Eric Elguero wrote:

> 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)

I would have thought you should ask:

length(ni$spy)

glmmadmb should be looking within the data object passed to it.

--  
David.


>
>
> 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.

Those function must be different. Get over it. Learn to pass the data  
in a common object.
>
> that puzzles me.
>
> _

David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list