[R] Regression

Chuck Cleland ccleland at optonline.net
Wed Nov 15 23:58:09 CET 2006


Alvaro wrote:
> I need to run a regression analysis with a large number of samples. Each
> sample (identified in the first file column) has its own x and y values. I
> will use the same model in all samples. How can I run the model for each
> sample? In SAS code I would use the "BY SAMPLE" statement.

  Here are a couple of ways:

by(warpbreaks, warpbreaks$tension, function(x) lm(breaks ~ wool, data = x))

library(nlme)

summary(lmList(breaks ~ wool | tension, warpbreaks))

?by

?lmList

>  
> 
> Alvaro
> 
>  
> 
>  
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894



More information about the R-help mailing list