Quantcast

Re: Extracting information from lm results

classic Classic list List threaded Threaded
1 message Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Extracting information from lm results

Dunbar, Michael J.
Hi Stephen

You should be able to find what you need either using str(lm1) or str(summary(lm1)). With the possible exception of the overall P value, which you can get from the F statistic and the degrees of freedom using the pf function. For the coefficients, its considered slightly better form to use coef(lm1)[x] rather than lm1$coefficients[x], simply because there is the coef extractor function provided.

cheers

Mike Dunbar


>>> "Stephen Thackeray" <[hidden email]> 02/05/2008 08:55:10 >>>
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: [hidden email]
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.


--
This message (and any attachments) is for the recipient ...{{dropped:15}}

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Loading...