Skip to content
Prev 22673 / 398502 Next

Why can't Anove (car package) see the data?

It is indeed a scope problem.  Anova.glm is calling functions which call
update and so is not calling glm in the correct frame.

Here is a fix:

fun.2 <- function(df){
    mod <- eval(substitute(
               glm(partic != 'not.work' ~ hincome + children + region,
               data=df, family=binomial), list(df=df)))
    Anova(mod)
}

which makes sure the actual data object gets stored in the call component
of the fitted model.  That is often a good idea, but Anova.glm needs
correcting.

This is a notorious problem in S, and although in ca 1998 I rewrote R's
update to work better (and better than S's) there is no getting away from
the S/R scope rules:  functions which have been called en route to (here)
Anova.II.LR.glm are not searched.

I'll correspond directly with John about possible solutions.  It should be
possible to use drop1.glm, or at least its ideas.
On Wed, 14 Aug 2002, John Fox wrote: