Re: [R] anova.lme error

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 15 Jun 2005 - 17:09:11 EST

You have already (incorrectly) filed this a bug report on *anova* and been asked to read the R FAQ and discuss this with the package maintainer.

Please do as we ask: only package maintainers can change contributed packages (here nlme).

On Tue, 14 Jun 2005, Nisha Mulakken wrote:

> Hi,
>
> I am working with R version 2.1.0, and I seem to have run into what looks
> like a bug. I get the same error message when I run R on Windows as well as
> when I run it on Linux.
>
> When I call anova to do a LR test from inside a function, I get an error.
> The same call works outside of a function. It appears to not find the right
> environment when called from inside a function. I have provided the code
> below.
>
> Thanks,
> Nisha Mulakken
>
> ############################
>
> myFunction <- function(myDataFrame) {
>
> # Less restricted
> fit1 <- gls(y ~ dose,
> weights=varIdent(form=~1|dose),
> data=myDataFrame)
>
> # more restricted
> fit2 <- gls(y ~ dose,
> data=myDataFrame)
>
> anova.results <- anova(fit1, fit2)
> anova.results
> }
>
> df <- data.frame( y=c(12,3,45,1,53,6),
> dose=c(0,10,200,0,10,200),
> time=c("4.00 hrs", "4.00 hrs", "6.00 hrs", "6.00 hrs",
> "8.00 hrs", "8.00 hrs"),
> time.hours=c(4, 4, 6, 6, 8, 8),
> rep=rep("a", 6)
> )
>
> ## This leads to the following error:
> ## Error in anova.lme(object = fit1, fit2) : Object "fit2" not found
> results <- myFunction(myDataFrame=df)
>
> #####################################################
> ## The same thing outside of a function
>
> # Less restricted
> fit3 <- gls(y ~ dose,
> weights=varIdent(form=~1|dose),
> data=df)
>
> # more restricted
> fit4 <- gls(y ~ dose,
> data=df)
>
> ## This works:
> anova(fit3, fit4)
>
> ## The results:
> ## > anova(fit3, fit4)
> ## Model df AIC BIC logLik Test L.Ratio p-value
> ## fit3 1 5 57.98998 54.92145 -23.99499
> ## fit4 2 3 55.75284 53.91172 -24.87642 1 vs 2 1.76286 0.4142
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Jun 15 17:15:57 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:39 EST