Another way is reg<-lapply(split(data,data$byvar),lm,formula=y~x) Justin BEM Elève Ingénieur Statisticien Economiste BP 294 Yaoundé. Tél (00237)9597295.
----- Message d'origine ---- De : Chuck Cleland <[EMAIL PROTECTED]> À : Alvaro <[EMAIL PROTECTED]> Cc : [email protected] Envoyé le : Mercredi, 15 Novembre 2006, 23h58mn 09s Objet : Re: [R] Regression 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]] > > ______________________________________________ > [email protected] 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 ______________________________________________ [email protected] 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. ___________________________________________________________________________ Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internaut [[alternative HTML version deleted]]
______________________________________________ [email protected] 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.
