Skip to content
Prev 200087 / 398503 Next

linear model and by()

On Nov 12, 2009, at 8:26 PM, Sam Albers wrote:

            
Beacuase the results are a layer deeper than summary is describing;
Try:
lapply(lm.r, summary)

(this theory tested with one of the standard datasets, Indometh:

library(utils)
data(Indometh)
reglist <- by(Indometh, Indometh$Subject, function(x) lm(conc~time,  
data=x) )
 > summary(reglist)
   Length Class Mode
1 12     lm    list
4 12     lm    list
2 12     lm    list
5 12     lm    list
6 12     lm    list
3 12     lm    list

Whereas, without the assignment to reglist I got a series of expected  
lm output, so by "works".
similarly:

lapply(lm.r, plot)
Sorry to not use your data but it's not in a form that lends itself  
very well to quick testing. If you had included the input commands I  
might have tried it.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT