[19234] in s-news-athena

home help back first fref pref prev next nref lref last post

[S] using apply() with update() of an lm()?

daemon@ATHENA.MIT.EDU (Doug Moog)
Wed Sep 15 16:04:47 1999

Message-Id: <4.1.19990915154346.009400e0@pop.cwru.edu>
Date: Wed, 15 Sep 1999 15:56:42 -0400
To: s-news@wubios.wustl.edu
From: Doug Moog <dbm3@po.cwru.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"


I'm totally perplexed.   The following (where my.df is a numeric data frame):

x.null <- lm(my.df[,1]~1, data=my.df)
apply(my.df[,-1], 2, function(x,y) {x.new_update(y,.~.+x);
sum(residuals(x.new)^2)}, y=x.null)

gives:  Error in FUN(X, y = ..1): Object "x" not found

But I don't get this error when 

x.null <- lm(runif(n)~runif(n))

where n is the number of rows in my.df (and no other n).

(The objective is to get a vector of the sums of squares of the residuals
of all variables in the data frame when modeled on the first one.)

Thanks


_________________________________________________________________________
Douglas B. Moog, Ph.D.                               phone: 216-368-1688
Senior Research Associate                          fax: 216-368-3691
Dept. of Geological Sciences 	      internet: dbm3@po.cwru.edu
Case Western Reserve University
Cleveland, OH  44106-7216
USA
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

home help back first fref pref prev next nref lref last post