Hi, R Users I find a problem in extracting the R-squared and P-value from the lm results described below (in Italic), *Residual standard error: 2.25 on 17 degrees of freedom* *Multiple R-squared: 0.001069, Adjusted R-squared: -0.05769 * *F-statistic: 0.01819 on 1 and 17 DF, p-value: 0.8943 * * * Any suggestions will be appreciated. Thanks. Wenjun [[alternative HTML version deleted]]
On 1/29/2010 9:04 AM, wenjun zheng wrote:> Hi, R Users > > I find a problem in extracting the R-squared and P-value from the lm results > described below (in Italic), > > *Residual standard error: 2.25 on 17 degrees of freedom* > *Multiple R-squared: 0.001069, Adjusted R-squared: -0.05769 * > *F-statistic: 0.01819 on 1 and 17 DF, p-value: 0.8943 * > * > * > Any suggestions will be appreciated. Thanks.?summary.lm In particular, see the 'Value' section which describes the components of the list returned when an lm() object is summarized. Notice the r.squared and coefficients components of the returned list.> Wenjun > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.-- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 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
> x <- 1:10 > y <- 2 + 1.5 * rnorm(10, x, 2) > m <- lm(y ~ x) > summary(m)$r.squared[1] 0.6056889> anova(m)$'Pr(>F)'[1] 0.0080142 NA Components of the summary() and anova() methods of lm() can be extracted. See names(summary(m)) names(anova(m)) to see the components one can extract. HTH, Dennis On Fri, Jan 29, 2010 at 6:04 AM, wenjun zheng <wjzheng09@gmail.com> wrote:> Hi, R Users > > I find a problem in extracting the R-squared and P-value from the lm > results > described below (in Italic), > > *Residual standard error: 2.25 on 17 degrees of freedom* > *Multiple R-squared: 0.001069, Adjusted R-squared: -0.05769 * > *F-statistic: 0.01819 on 1 and 17 DF, p-value: 0.8943 * > * > * > Any suggestions will be appreciated. Thanks. > > Wenjun > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
Hi r-help-bounces at r-project.org napsal dne 29.01.2010 15:04:39:> Hi, R Users > > I find a problem in extracting the R-squared and P-value from the lmresults> described below (in Italic), > > *Residual standard error: 2.25 on 17 degrees of freedom* > *Multiple R-squared: 0.001069, Adjusted R-squared: -0.05769 * > *F-statistic: 0.01819 on 1 and 17 DF, p-value: 0.8943 * > * > * > Any suggestions will be appreciated. Thanks.What about filling such question in CRAN search facility. When I put your subject line into it I got many relevant hits. If you want to see how summary(fit) is structured than use str(summary(fit)) If I remember it correctly summary(fit)$r.sqared but you can easily find it yourself. Regards Petr> > Wenjun > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.