Hi,
I'm encountering a very odd problem with calls to anova.mlm() from within a
function.
Consider the following code (data.n is a matrix of numeric values):
mlmfit <- lm(data.n ~ 1)
mlmfit0 <- lm(data.n ~ 0)
print(mlmfit)
anova(mlmfit,mlmfit0,test="Spherical")
If I run it just like this from the console, it works just fine. If,
however, I call it from within a function, e.g. using
fct <- function(data.k) {
 # same code with data.n replaced by data.k
}
fct(data.n)
It gives me> fct(data.n)
Call:
lm(formula = data.k ~ 1)
Coefficients:
...
Error in anova.mlmlist(object = mlmfit, mlmfit0, test = "Spherical") :
        Object "mlmfit" not found
What causes mlmfit to "disappear" between two lines? I haven't got
the
slightest clue where to look for an answer...
Thank you very much for your help.
Bela Bauer
-- 
Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie!
Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl
Sorry, forgot to mention: I'm using R 2.1.0 on a x86 Debian Sarge system. I can reproduce the behaviour on a similar system. Unfortunately, I don't have any other OS with R installed available to me. Thanks again, Bela -- Bela Bauer - bela_b at gmx.net PGP 0x97529F5C http://www.aitrob.de
Bela Bauer wrote:>Hi, > >I'm encountering a very odd problem with calls to anova.mlm() from within a >function. > >Consider the following code (data.n is a matrix of numeric values): > >mlmfit <- lm(data.n ~ 1) >mlmfit0 <- lm(data.n ~ 0) >print(mlmfit) >anova(mlmfit,mlmfit0,test="Spherical") > >If I run it just like this from the console, it works just fine. If, >however, I call it from within a function, e.g. using > >fct <- function(data.k) { > # same code with data.n replaced by data.k >} >fct(data.n) > >It gives me > > >>fct(data.n) >> >> > >Call: >lm(formula = data.k ~ 1) > >Coefficients: >... > >Error in anova.mlmlist(object = mlmfit, mlmfit0, test = "Spherical") : > Object "mlmfit" not found > >What causes mlmfit to "disappear" between two lines? I haven't got the >slightest clue where to look for an answer... > >Thank you very much for your help. > >This looks like a bug in the anova.mlm or anova.mlmlist functions. One of them is looking in the wrong place for mlmfit. Duncan Murdoch