[R] extracting F, df and r squared using "sapply"?
Michael Rennie
mrennie at utm.utoronto.ca
Fri Feb 18 23:05:44 CET 2005
Hi, All
How does one remove relevant information from a regression output besides
just the coefficients?
I've been able to modify the example given under "help(by)" to give me some
additional information, but not everything I need.
If you adjust the call statement from what is listed by adding the summary
statement like so:
tmp <- by(warpbreaks, tension, function(x) summary(lm(breaks ~ wool, data=x)))
sapply(tmp, coef)
I am able to get the coefficients and the p-value (as well as 5 other rows
of information I don't need, corresponding to St. error of the
coefficients, t-values and the p-value of the intercept, but I can delete
all this later).
If you look at tmp, all the F statistics, r-squared values, etc. are there,
but is there an easy way to get at them reported in a tabulated form?
Specifically, is there a simple way I can adjust the "sapply" command to
extract the F statistic, r squared, and degrees of freedom (in addition to
the coefficients) and have them appear as rows in the output? Ultimately, I
have 200+ groups that I am running regressions on in the same dataset, so I
need some way to extract the relevant information in a tabulated form.
and no smart-alec comments about bonferonni corrections :)
Thanks,
Mike
Michael Rennie
Ph.D. Candidate
University of Toronto at Mississauga
3359 Mississauga Rd. N.
Mississauga, ON L5L 1C6
Ph: 905-828-5452 Fax: 905-828-3792
More information about the R-help
mailing list