[R] getting the p-value from lm as a list object
Thomas Petzoldt
thpe at simecol.de
Fri Oct 31 17:21:00 CET 2008
eric lee wrote:
> Hi,
>
> I'm trying to get the p-value from the 'lm' regression function as a list
> object. For example, I can get r^2 from the following code by entering
> summary(fm)$r.squared. Is there a way to get the p-value? If not, is there
> a function where I can enter the f-value and degrees of freedom to get the
> p-value? Thanks.
>
> x <- c(1,2,3,4,5,6,7,8,9,10)
> y <- c(1,2,3,4,4,5,6,8,1,9)
>
> fm <- lm(y ~ x)
> str(summary(fm))
What about the following (taken from stats:::print.summary.lm):
x <- c(1,2,3,4,5,6,7,8,9,10)
y <- c(1,2,3,4,4,5,6,8,1,9)
fm <- lm(y ~ x)
summary(fm) # for comparison only
sfm <- summary(fm)
pf(sfm$fstatistic[1], sfm$fstatistic[2], sfm$fstatistic[3],
lower.tail = FALSE)
Thomas P.
More information about the R-help
mailing list