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

David Winsemius dwinsemius at comcast.net
Fri Feb 5 18:07:54 CET 2010


On Feb 5, 2010, at 12:00 PM, Turchin, Michael wrote:

> You should be able to access the p-value using the $coefficients  
> variable, which is part of summary.
>
> Try:
>
> results <- summary(lm(speed~dist, cars))
> results$coefficients
>
> and then:
>
> results$coefficients[x]

The "coefficients" element of the summary argument is a two  
dimensional structure. You might be able to extract a number this way  
but choosing the correct number, in this case 8, for the p-value  
associated with the dist parameter, might not be so obvious.

-- 
Best

>
> where x is the location of particular p-value, or coefficient  
> supplied, you want, from the results$coefficient vector.
>
> Hope this helps,
> ~Michael
> ________________________________________
> From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On  
> Behalf Of Trafim Vanishek [rdapamoga at gmail.com]
> Sent: Friday, February 05, 2010 11:54 AM
> To: r-help at r-project.org
> Subject: [R] Extract p-value from lm for the whole model
>
> 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
>
> summary(lm(speed~dist, cars))
>
> Thanks a lot!

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list