Skip to content
Prev 176152 / 398503 Next

extract the p value of F statistics from the lm class

On 05-Apr-09 08:18:27, tedzzx wrote:
Maybe you were looking in the wrong place. A few lines above the
output from x$fstatistic

  x$fstatistic
     value    numdf    dendf 
  72.04064  1.00000 31.00000

you will find

  F-statistic: 72.04 on 1 and 31 DF,  p-value: 1.379e-09

and therefore will find the P-value. However, maybe that is not
the question you really wanted to ask. If that is what I think it
may be, you could

1:  Observe that x$fstatistic is a vector with 3 values which
    are: value of F; numerator df; demoninator df
2:  Note (from ?pf)
    pf(q, df1, df2, ncp, lower.tail = TRUE, log.p = FALSE)
3:  Therefore do
    pf(x$fstatistic[1],x$fstatistic[2],x$fstatistic[3],lower.tail=FALSE)
    # [1] 1.378626e-09

Note that the P-value is not in the list of values returned by lm()
although $fstatistic is one of the values. The computation of the
P-value in the displayed output from summary.lm() is done by the
'print' method for summary.lm() (just as in [3] above).

Hoping this helps,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 05-Apr-09                                       Time: 13:12:45
------------------------------ XFMail ------------------------------