Re: [R] Simultaneously summarizing many models

From: ONKELINX, Thierry <Thierry.ONKELINX_at_inbo.be>
Date: Fri, 22 Feb 2008 13:00:22 +0100

Store the models into a list and the use an apply-function.

x=1:10 #this creates some example data
y=rnorm(10)
m1=lm(x~y)
m2=lm(x~1)
Models <- list(m1, m2)
lapply(Models, summary)

HTH, Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx_at_inbo.be
www.inbo.be

Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney

-----Oorspronkelijk bericht-----
Van: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] Namens Christoph Scherber Verzonden: vrijdag 22 februari 2008 12:46 Aan: r-help_at_stat.math.ethz.ch
Onderwerp: [R] Simultaneously summarizing many models

Dear R users,

Letīs say I have 10 models, each named m1,m2,m3..., and I would like to summarize them automatically and simultaneously - e.g., to extract parameter estimates later on from all models; how can I do that?

I have tried:

x=1:10 #this creates some example data
y=rnorm(10)

m1=lm(x~y)
m2=lm(x~1)

sum.lms=function(x)summary(paste("m",x,sep="")) sum.lms(1:2)

but the paste() function always returns "m1" "m2" in quotation marks instead of m1 m2

Do you know a way around this? I guess I would need to use expression() or substitute() but I donīt know how to construct m1, m2... without the quotation marks.

Thanks very much for your help!

Best wishes,

Christoph

(using R 2.5.1 on Windows XP SP2)

-- 
Dr. Christoph Scherber
DNPW, Agroecology
University of Goettingen
Waldweg 26
D-37073 Goettingen
Germany

phone +49(0)551 39 8807
fax   +49(0)551 39 8806
homepage www.gwdg.de/~cscherb1


______________________________________________
R-help_at_r-project.org 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.
______________________________________________
R-help_at_r-project.org 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.
Received on Fri 22 Feb 2008 - 12:03:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 22 Feb 2008 - 13:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive