Skip to content
Prev 275378 / 398506 Next

extract the p value

It's not directly extractable since it's calculated on the fly in the
printing method. If you type stats:::print.summary.lm,  you can see
the code the leads to the calculation: It's basically (I'm leaving out
some formatting stuff):

pf(x$fstatistic[1L], x$fstatistic[2L], x$fstatistic[3L], lower.tail = FALSE)

where the fstatistic is calculated in summary.lm. You can write a
little helper to calculate this yourself -- just something like

getModelPValue <- function(m) {
    stopifnot(inherits(m, "lm"))
    s <- summary.lm(m)
    pf(s$fstatistic[1L], s$fstatistic[2L], s$fstatistic[3L], lower.tail = FALSE)
}

And you can just extract the necessary parts of summary.lm if speed is
a concern.

Hope this helps,

Michael
On Mon, Oct 24, 2011 at 1:47 PM, Jim Bouldin <bouldinjr at gmail.com> wrote: