Dear S users,
Thanks to everyone who responded to my question (reproduced at
the end of this message). As it turns out it was not a problem
with stepAIC, but with my understanding of the S scoping rules.
Two solutions were suggested to me, both of which solved the
problem. The first is to assign "data" to frame 1, using
assign("data",data,frame=1). The other solution also works but
I don't know why: change the call to glm to
fit <- do.call("glm", list(fo = y ~ ., data = data, family = binomial))
Best regards,
-Ad Feelders
---------------------------- Original Message ----------------------------
Subject: [S] problem with stepAIC?
From: ad@cs.uu.nl
Date: Fri, January 13, 2006 4:39 pm
To: s-news@wubios.wustl.edu
--------------------------------------------------------------------------
Dear S users,
I'm working with S-plus 6 under Windows 2000.
I've written the following function just to make clear what
exactly the problem is I'm running in to:
function(data)
{
fit <- glm(y ~ ., data = data, family = binomial)
fit2 <- stepAIC(fit)
fit2
}
When I call this function from the command line (say the function
is called "test"), I get the following error message:
> test(somedataset)
Start: AIC= 701.5
y ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8
Problem in eval(oc, list()): Object "data" not found
When I use traceback, I can see the error is generated by stepAIC
(from the MASS library), but I haven't got a clue what the problem is.
Has anybody got an idea what causes this error, and how it can be solved?
Thanks for your help.
-Ad Feelders
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|