s-news
[Top] [All Lists]

Problems with anova.gls when calling within a function

To: <s-news@lists.biostat.wustl.edu>
Subject: Problems with anova.gls when calling within a function
From: "Steffen Barembruch" <steffen@barembruch.de>
Date: Thu, 1 Feb 2007 19:30:12 +0100
In-reply-to:
References:
Thread-index: Acc0C7EsuM0kp7HIS56yba2edqrnBgD2A64gA5JcHeA=
Hello!
 
I've got a problem with calling "anova.gls" within a function. Here is my code, which I am executing within a function:
gls.lr <- gls(formula.fixed, data = "" na.action = "" method="ML")
lme.lr  <- lme(formula.fixed, data = "" random = formula.random,  na.action= "" method="ML")
LR.test <- anova.gls(gls.lr, lme.lr)
(formula.random and formula.fixed have been assigned before, to be the appropriate formulae)
 
I get an error, that the object "lme.lr" and the object "gls.lr" are not found.
I think this is, because anova.gls looks for objects in the working directory and not in the current frame. When I execute the same code at the command line (not within a function), it does work.
And when I assign the objects to the working directory as following, it also works
gls.lr <- gls(formula.fixed, data = "" na.action = "" method="ML")
assign("gls.lr", gls.lr, where=1)
lme.lr  <- lme(formula.fixed, data = "" random = formula.random, na.action= "" method="ML")
assign("lme.temp1", lme.temp1, where=1)
LR.test <- anova.gls(gls.lr, lme.lr)
 
Does anyone know anything about this? Why does this error occur? Do I have to assign the objects to the working directory beforehand? Did I do anything wrong
 
Surprisingly this problem does not occur, when you call anova.gls with one parameter, like
anova.gls(gls.lr)
 
Thanks a lot. I hope someone got some insight for me
Steffen Barembruch
<Prev in Thread] Current Thread [Next in Thread>
  • Problems with anova.gls when calling within a function, Steffen Barembruch <=