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

______________________________________________
R-help@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.

Reply via email to