[R] Extract p-value from lm for the whole model

David Winsemius dwinsemius at comcast.net
Fri Feb 5 18:02:01 CET 2010


On Feb 5, 2010, at 11:54 AM, Trafim Vanishek wrote:

> Dear all,
>
> I would like to ask how to extract the p-value for the whole model  
> from
> summary(lm).
> This didn't help a lot summary.lm

I disagree. The help page tells you that "coefficients" has the p- 
values sogo ahead and get them:

 > summary.lm(lm(speed~dist, cars))$coefficients
              Estimate Std. Error  t value     Pr(>|t|)
(Intercept) 8.2839056 0.87438449 9.473985 1.440974e-12
dist        0.1655676 0.01749448 9.463990 1.489836e-12

That is a table or matrix (it doesn't really matter for our purposes)  
and can be address by either numbers or names. Here is how to do it  
with names.

 > summary.lm(lm(speed~dist, cars))$coefficients["dist","Pr(>|t|)"]
[1] 1.489836e-12


>
> summary(lm(speed~dist, cars))

-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list