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

S Ellison S.Ellison at lgc.co.uk
Fri Feb 5 18:19:00 CET 2010

> I would like to ask how to extract the p-value for the whole model  
> from
> summary(lm).

If you mean the p-value given at the end of the summary() printout, it
isn;t held in the summary object. But information to get it is. Using
the ?lm example:

     ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
     trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
     group <- gl(2,10,20, labels=c("Ctl","Trt"))
     weight <- c(ctl, trt)
    lm.D9 <- lm(weight ~ group)

  pf(fstat[1], fstat[2], fstat[3], lower.tail=FALSE)

That's a p-value for a test of weight~1 versus weight~group, so you
could also get it from 
anova(lm.D0, lm.D9)

and doubtless lots of other ways.

This email and any attachments are confidential. Any use...{{dropped:8}}

More information about the R-help mailing list