Skip to content
Prev 81660 / 398502 Next

anova.gls from nlme on multiple arguments within a function fails

You've posed an excellent question with simple and elegant, 
reproducible example.  I've seen no replies, so I will attempt a partial 
response.  RSiteSearch("lexical scoping") produced some potentially 
useful comments (e.g., 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/37769.html), but nothing 
that allowed me to work around the problem.

	  The following modification of your example makes it clear that 
"anova.lme" (called by "anova.gls") choked on the second argument not 
the first:

 > dummy2 <- function(obj)
+   {
+     obj2 <- obj[[2]]
+     anova(obj[[1]], obj2)
+   }
 > dummy2(list(fm1, fm2))
Error in anova.lme(object = obj[[1]], obj2) :
	object "obj2" not found

	  The following helped isolate this further to "dots <- list(...)", the 
second line in "anova.lme":

debug(anova.lme)
dummy2(list(fm1, fm2))

	  I don't know why your example fails, especially "anova.lm" worked. 
Also, there should be a way  to use something like "assign" to work 
around this problem, but nothing I tried worked.

	  I know this is not a complete reply, but I hope it helps.
	  spencer graves
Markus Jantti wrote: