[R-sig-eco] Extracting information from lm results

Christoph Meyer christoph.meyer at uni-ulm.de
Fri May 2 11:06:48 CEST 2008


Hi Steve,

you can extract this information from the summary of your linear
regressions, i.e. summary(lm1).

e.g.

sum.lm1=summary(lm1)
sum.lm1$coef[2,2]    #this gives you the SE of the slope
sum.lm1$r.squared    #this gives you the R2
and so on...
This should be clear from a look at str(sum.lm1).

Hope that helps,

Christoph




Friday, May 2, 2008, 9:55:10 AM, you wrote:

> Dear all,

> I suspect that this might be a bit basic, but here goes anyway...

> I am soon to run a large number of linear regressions and I would
> like to extract a number of details from the models, and then
> collate them in a dataframe as a summary of the overall block of
> analyses. I can successfully extract the intercept and slope by using, for example:

> lm1<-lm(ASTF~Year,na.action=na.omit,subset=yr10==T)
> a1<-lm1$coefficients[1]
> b1<-lm1$coefficients[2]
> out1<-cbind("ASTF","1996-2005",lm1$coefficients[1],lm1$coefficients[2])

> However, I also would like to extract the following too:

> 1) the number of data points in the analysis, n
> 2) the standard error of the slope
> 3) the P value
> 4) the R-squared value

> Is it possible to extract these parameters in the same way as the
> slope and intercept, to save a lot of typing?

> Any help much appreciated!

> Steve Thackeray



> Dr Stephen Thackeray 
> Lake Ecosystem Group
> CEH Lancaster
> Lancaster Environment Centre
> Library Avenue
> Bailrigg
> Lancaster
> LA1 4AP

> Email: sjtr at ceh.ac.uk
> Tel: +44 (0) 1524 595852
> Fax: +44 (0) 1524 61536

> Disclaimer: Any views or opinions expressed in this mail or any
> files transmitted with it are those of the author and do not
> represent the views of NERC unless otherwise explicitly stated. The
> information contained in this email may be subject to public
> disclosure under the Freedom of Information Act 2000. Unless the
> information is legally exempt from disclosure, the confidentiality
> of this e-mail and your reply cannot be guaranteed.



***************************************************************
Dr. Christoph Meyer
Institute of Experimental Ecology
University of Ulm
Albert-Einstein-Allee 11
D-89069 Ulm
Germany
Phone:  ++49-(0)731-502-2675
Fax:    ++49-(0)731-502-2683
Mobile: ++49-(0)1577-156-7049
E-mail: christoph.meyer at uni-ulm.de
http://www.uni-ulm.de/nawi/nawi-bio3.html



More information about the R-sig-ecology mailing list